Skip to content

fix: validate creds #222

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 8, 2025
Merged

fix: validate creds #222

merged 7 commits into from
May 8, 2025

Conversation

blva
Copy link
Collaborator

@blva blva commented May 8, 2025

fixes #221

  • validates the API credentials on startup. If no connection string is provided, it fails to initialize. If it is provided and valid, then it proceeds with initialization
  • adds a fallback in telemetry, if the credentials are invalid, it emits events to the unauth endpoint instead
  • adds unit tests to api client

@blva blva marked this pull request as ready for review May 8, 2025 10:37
@blva blva requested a review from a team as a code owner May 8, 2025 10:37
}

// For 401 errors, fall through to unauthenticated endpoint
delete headers["Authorization"];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we ever get here? Doesn't hurt to have it just in case, but also wondering if I'm not seeing something.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, if someone sets connection string + invalid api keys, we let them start the server

Copy link
Collaborator

@gagik gagik May 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if fetch errors, we'd get here right? actually not sure

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we'd get here if we get a 401, if any other error, we do nothing

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, my point was that we need to get a 401 wrapped in a ApiClientError, which fetch shouldn't be doing, should it? The only place we can throw ApiClientError is on line 146, but that explicitly avoids throwing for 401s.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it! i think you're right, let me try to fix it

@blva blva merged commit e200559 into main May 8, 2025
17 checks passed
@blva blva deleted the telemetry-update branch May 8, 2025 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Server starts even with invalid api credentials and no connection string
3 participants