From 3c3679e05d150bec2919ee1926de4ea1b69a0dc4 Mon Sep 17 00:00:00 2001 From: nicolasgere Date: Tue, 27 Feb 2024 09:47:23 -0800 Subject: [PATCH] [BUG]: fix server quota error handling (#1779) ## 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 --- chromadb/quota/__init__.py | 1 + chromadb/server/fastapi/__init__.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/chromadb/quota/__init__.py b/chromadb/quota/__init__.py index 82365ff1bd1..eebc8f70b00 100644 --- a/chromadb/quota/__init__.py +++ b/chromadb/quota/__init__.py @@ -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, diff --git a/chromadb/server/fastapi/__init__.py b/chromadb/server/fastapi/__init__.py index fa057b90d29..5eccc54d819 100644 --- a/chromadb/server/fastapi/__init__.py +++ b/chromadb/server/fastapi/__init__.py @@ -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}"},