-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[BUG]: Thin client imports #2466
Conversation
Reviewer ChecklistPlease leverage this checklist to ensure your code review is thorough before approving Testing, Bugs, Errors, Logs, Documentation
System Compatibility
Quality
|
This stack of pull requests is managed by Graphite. Learn more about stacking. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good, is there a way to add a test to ensure this doesn't happen again?
- Added a step to verify thin client package import works
I've added a test-package.sh step after the thin client build that should install the package and import it. We can try to refactor the CI for client tests so that it uses deps from |
oh sorry I missed that, that seems perfect |
@@ -341,7 +341,7 @@ def auth_and_get_tenant_and_database_for_request( | |||
if not self.authn_provider: | |||
return (tenant, database) | |||
|
|||
user_identity = self.authn_provider.authenticate_or_raise(headers) | |||
user_identity = self.authn_provider.authenticate_or_raise(dict(headers)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to fix a header check that was previously self._token_transport_header.value not in headers
, which doesn't work with dict.
@@ -232,4 +231,6 @@ def authenticate_or_raise(self, headers: Headers) -> UserIdentity: | |||
time.sleep( | |||
random.uniform(0.001, 0.005) | |||
) # add some jitter to avoid timing attacks | |||
from fastapi import HTTPException |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really want to import in the hot path here? Why do we need this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a good point. I had it initially in the __init__
as a self.HTTPException
. Shall I move it back?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -100,11 +102,11 @@ def __init__(self, system: System) -> None: | |||
"BasicAuthenticationServerProvider.authenticate", OpenTelemetryGranularity.ALL | |||
) | |||
@override | |||
def authenticate_or_raise(self, headers: Headers) -> UserIdentity: | |||
def authenticate_or_raise(self, headers: Dict[str, str]) -> UserIdentity: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a breaking change for anyone overriding auth. We should be more careful here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. But the use of starlette
and fastapi
here was already a breaking change for the thin client, which did not require (or import) either of those. Technically, duck-typing helps us here too.
## Description of changes *Summarize the changes made by this PR.* - Improvements & Bug fixes - Fix thin client package bug introduced by #2466 by @tazarov - Do this as opposed to #2490 - as it is cleaner and more explicit. Making it less brittle to changes. - New functionality - .. ## Test plan *How are these changes tested?* - [ ] Tests pass locally with `pytest` for python, `yarn test` for js, `cargo test` for rust ## Documentation Changes *Are all docstrings for user-facing APIs updated if required? Do we need to make documentation changes in the [docs repository](https://github.com/chroma-core/docs)?*
Description of changes
Closes #2459
Summarize the changes made by this PR.
Test plan
How are these changes tested?
pytest
for python,yarn test
for js,cargo test
for rustDocumentation Changes