Skip to content

Commit

Permalink
[BUG]: fix server quota error handling (#1779)
Browse files Browse the repository at this point in the history
## Description of changes

*Summarize the changes made by this PR.*
 - Improvements & Bug fixes
	 - Fixing a bug with quota error handling on the fast API server
  • Loading branch information
nicolasgere committed Feb 27, 2024
1 parent d4230b3 commit 3c3679e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions chromadb/quota/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def __init__(self, system: System) -> None:

def static_check(self, metadatas: Optional[Metadatas] = None, documents: Optional[Documents] = None,
embeddings: Optional[Embeddings] = None, collection_id: Optional[str] = None):

if not self.should_enforce:
return
metadata_key_length_quota = self._quota_provider.get_for_subject(resource=Resource.METADATA_KEY_LENGTH,
Expand Down
2 changes: 1 addition & 1 deletion chromadb/server/fastapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def app(self) -> fastapi.FastAPI:
def root(self) -> Dict[str, int]:
return {"nanosecond heartbeat": self._api.heartbeat()}

async def quota_exception_handler(request: Request, exc: QuotaError):
async def quota_exception_handler(self, request: Request, exc: QuotaError):
return JSONResponse(
status_code=429,
content={"message": f"quota error. resource: {exc.resource} quota: {exc.quota} actual: {exc.actual}"},
Expand Down

0 comments on commit 3c3679e

Please sign in to comment.