Skip to content
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

[ENH]: Improve tenant and DB validation handling #1494

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
14 changes: 14 additions & 0 deletions chromadb/api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,20 @@ def _validate_tenant_database(self, tenant: str, database: str) -> None:
raise ValueError(
"Could not connect to a Chroma server. Are you sure it is running?"
)
except requests.exceptions.HTTPError as ex:
if ex.response.status_code in [401, 403]:
raise ValueError(
"Authentication error. Have you configured your client to use authentication?"
)
if ex.response.status_code == 404:
raise ValueError(
f"It appears your Chroma server is running an older version of Chroma {self.get_version()}. "
Copy link
Collaborator

Choose a reason for hiding this comment

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

This error message could be a bit confusing, its only printing the client version right?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh I see, its saying the validation routes don't exist, maybe we can make that clearer?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now it looks like this:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/tazarov/experiments/chroma-experiments/oss/1480-better-tenant-db-validation/chromadb/__init__.py", line 182, in HttpClient
    return ClientCreator(tenant=tenant, database=database, settings=settings)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tazarov/experiments/chroma-experiments/oss/1480-better-tenant-db-validation/chromadb/api/client.py", line 148, in __init__
    self._validate_tenant_database(tenant=tenant, database=database)
  File "/Users/tazarov/experiments/chroma-experiments/oss/1480-better-tenant-db-validation/chromadb/api/client.py", line 444, in _validate_tenant_database
    raise ValueError(
ValueError: It appears you are using newer version of Chroma client (v0.4.18) that is not compatible with  Chroma server (v0.4.12). Please upgrade your server to the latest version.

"Please upgrade to the latest version."
)
else:
raise ValueError(
f"Could not connect to tenant {tenant}. Are you sure it exists?"
)
# Propagate ChromaErrors
except ChromaError as e:
raise e
Expand Down