-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BUG] UUID should be uuid type not str (#1644)
## Description of changes *Summarize the changes made by this PR.* - Improvements & Bug fixes - fastapi_utils needs to push the uuid as a UUID type not str to get_collection. - Refactored _uuid into a util - New functionality - None
- Loading branch information
Showing
3 changed files
with
11 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
from uuid import UUID | ||
from starlette.responses import JSONResponse | ||
|
||
from chromadb.errors import ChromaError | ||
from chromadb.errors import ChromaError, InvalidUUIDError | ||
|
||
|
||
def fastapi_json_response(error: ChromaError) -> JSONResponse: | ||
return JSONResponse( | ||
content={"error": error.name(), "message": error.message()}, | ||
status_code=error.code(), | ||
) | ||
|
||
def string_to_uuid(uuid_str: str) -> UUID: | ||
try: | ||
return UUID(uuid_str) | ||
except ValueError: | ||
raise InvalidUUIDError(f"Could not parse {uuid_str} as a UUID") |