Skip to content

Conversation

grf53
Copy link

@grf53 grf53 commented Aug 25, 2025

Description of changes

  • Bug fixes
    • I got an AttributeError during using get operation through the chromadb server running with fastapi.
      This raises by calling .tolist() on the list, so simply removed calling .tolist(), then the bug is fixed.
 File "/my/python/install/localtion/site-packages/chromadb/server/fastapi/__init__.py", line 1128, in get
   cast(Embedding, embedding).tolist()
   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'list' object has no attribute 'tolist'

Test plan

How are these changes tested?

  • Tests pass locally with pytest for python, yarn test for js, cargo test for rust

Migration plan

Are there any migrations, or any forwards/backwards compatibility changes needed in order to make sure this change deploys reliably?

Observability plan

What is the plan to instrument and monitor this change?

Documentation Changes

Are all docstrings for user-facing APIs updated if required? Do we need to make documentation changes in the docs section?

Copy link

Reviewer Checklist

Please leverage this checklist to ensure your code review is thorough before approving

Testing, Bugs, Errors, Logs, Documentation

  • Can you think of any use case in which the code does not behave as intended? Have they been tested?
  • Can you think of any inputs or external events that could break the code? Is user input validated and safe? Have they been tested?
  • If appropriate, are there adequate property based tests?
  • If appropriate, are there adequate unit tests?
  • Should any logging, debugging, tracing information be added or removed?
  • Are error messages user-friendly?
  • Have all documentation changes needed been made?
  • Have all non-obvious changes been commented?

System Compatibility

  • Are there any potential impacts on other parts of the system or backward compatibility?
  • Does this change intersect with any items on our roadmap, and if so, is there a plan for fitting them together?

Quality

  • Is this code of a unexpectedly high quality (Readability, Modularity, Intuitiveness)

Copy link
Contributor

This PR addresses a bug in the FastAPI server implementation for ChromaDB where an AttributeError was raised during the 'get' operation. The error occurred due to the use of '.tolist()' on a Python list object (embedding), which does not have this method. The code now simply casts the embedding as Embedding without calling '.tolist()', resolving the exception.

This summary was automatically generated by @propel-code-bot

@@ -1123,8 +1123,7 @@ def process_get(request: Request, raw_body: bytes) -> GetResult:

if get_result["embeddings"] is not None:
get_result["embeddings"] = [
cast(Embedding, embedding).tolist()
for embedding in get_result["embeddings"]
cast(Embedding, embedding) for embedding in get_result["embeddings"]
Copy link
Contributor

Choose a reason for hiding this comment

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

[Documentation]

The fix correctly addresses the AttributeError by removing the .tolist() call. However, consider adding a comment explaining that embeddings can be either numpy arrays or lists, and this code handles both cases by simply casting without conversion.

Suggested change
cast(Embedding, embedding) for embedding in get_result["embeddings"]
# Embeddings can be numpy arrays or lists - cast handles both
cast(Embedding, embedding) for embedding in get_result["embeddings"]

Committable suggestion

Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant