chroma-core / chroma-core/chroma
[Bug]: OpenAPI Docs Generation Fails with PackageNotFoundError for "chromadb"
- Dominant language
- Rust
- Stars
- 29.3k
- Forks
- 2.5k
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 38
Description
### What happened?
When running the official [chromadb/chroma] Docker image, the /docs endpoint fails to load due to a missing package metadata error for the [chromadb] package. Although the core API endpoints (e.g., /api/v2/auth/identity) work correctly, the /openapi.json endpoint returns an HTTP 500 with a PackageNotFoundError.
Steps to Reproduce:
Pull the latest Docker image:
docker pull chromadb/chroma:latest
Run the container on port 8000:
docker run -d -p 8000:8000 chromadb/chroma
Access the interactive documentation in your browser at http://localhost:8000/docs.
Expected Behavior:
The interactive API documentation should load successfully, presenting the OpenAPI schema.
Actual Behavior:
The /docs (and /openapi.json) endpoint returns an HTTP 500 with the following traceback in the logs:
ERROR: [timestamp] No package metadata was found for chromadb
Traceback (most recent call last):
...
File "/chroma/chromadb/server/fastapi/__init__.py", line 246, in generate_openapi
version=importlib.metadata.version("chromadb"),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/importlib/metadata/__init__.py", line 565, in from_name
raise PackageNotFoundError(name)
importlib.metadata.PackageNotFoundError: No package metadata was found for chromadb
Environment:
OS: Windows (via Docker)
Docker Image: chromadb/chroma:latest
Python Version (inside container): 3.11
Client code (for reference):
******************
import chromadb
from functions import readtextfiles, chunksplitter, getembedding
chromaclient = chromadb.HttpClient(host="localhost", port=8000)
textdocspath = r"C:\Dev\Python Projects\PlayAndLearn\textdocs"
text_data = readtextfiles(textdocspath)
collection_name = "buildragwithpython"
collection = chromaclient.get_or_create_collection(name=collection_name, metadata={"hnsw:space": "cosine"})
for filename, text in text_data.items():
chunks = chunksplitter(text)
embeds = getembedding(chunks)
chunknumber = list(range(len(chunks)))
ids = [filename + str(index) for index in chunknumber]
metadatas = [{"source": filename} for index in chunknumber]
collection.add(ids=ids, documents=chunks, embeddings=embeds, metadatas=metadatas)
print("Collections:", chromaclient.list_collections())
collection = chromaclient.get_collection("buildragwithpython")
print("Collection details:", collection)
docs = collection.get()
print("Documents in collection:", docs)
***********************
Additional Context:
The core API endpoints work correctly as seen when calling /api/v2/auth/identity.
The error in question is solely related to generating the OpenAPI docs.
A temporary workaround is to patch the OpenAPI generation code to handle missing package metadata gracefully (e.g., returning "unknown" when metadata is not found).
Proposed Fix or Workaround:
Catch the PackageNotFoundError in the OpenAPI generation logic and return a default version, such as "unknown", so that the schema generation succeeds.
### Versions
Chroma Docker Image:
[chromadb/chroma:latest](vscode-file://vscode-app/c:/Users/Rik/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-sandbox/workbench/workbench.html) (Digest: sha256:e0e78dc7609a599b63c99753442c7d01b1d3d369ce0e3bf3e0540536fec4fa7a)
Python:
The container is using Python 3.11 (observed via the paths in logs, e.g. /usr/local/lib/python3.11/...).
Your local development environment (running importdocs.py) is using a virtual environment, likely Python 3.11 (confirm with python --version if needed).
Operating System:
Windows 10/11 (Running Docker on a Windows machine, as indicated by C:\Dev\... paths)
Docker:
Docker version :
Cloud integration: v1.0.35+desktop.5
Version: 24.0.7
API version: 1.43
Go version: go1.20.10
Git commit: afdd53b
Built: Thu Oct 26 09:08:44 2023
OS/Arch: windows/amd64
Context: default
Server: Docker Desktop 4.26.1 (131620)
Engine:
Version: 24.0.7
API version: 1.43 (minimum version 1.12)
Go version: go1.20.10
Git commit: 311b9ff
Built: Thu Oct 26 09:08:02 2023
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.25
GitCommit: d8f198a4ed8892c764191ef7b3b06d8a2eeb5c7f
runc:
Version: 1.1.10
GitCommit: v1.1.10-0-g18a0cb0
docker-init:
Version: 0.19.0
GitCommit: de40ad0
Additional Context:
The python code in [importdocs.py](vscode-file://vscode-app/c:/Users/Rik/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-sandbox/workbench/workbench.html) interacts with the Chroma server normally, but the /docs endpoint fails due to missing package metadata for the [chromadb](vscode-file://vscode-app/c:/Users/Rik/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-sandbox/workbench/workbench.html) package.
### Relevant log output
```shell
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Read chromadb/server/fastapi/__init__.py at generate_openapi, where the traceback shows package version lookup failing. Reproduce the issue by running the chromadb/chroma Docker image and requesting /openapi.json or /docs. Done means the OpenAPI schema loads successfully without PackageNotFoundError when chromadb package metadata is unavailable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, python
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100