Skip to content

fix(embedding): raise API error message for Cloudflare and HuggingFace failures - #7999

Open
pcbeingused333 wants to merge 1 commit into
chroma-core:mainfrom
pcbeingused333:fix-embedding-errors-c1736
Open

pcbeingused333 wants to merge 1 commit into
chroma-core:mainfrom
pcbeingused333:fix-embedding-errors-c1736

Conversation

@pcbeingused333

Copy link
Copy Markdown

Cause. CloudflareWorkersAIEmbeddingFunction.__call__ checked "result" not in resp and "data" not in resp["result"]. With and, a failed response (e.g. wrong key/account: {"success": false, "errors": [...], "result": null}) skips the check, and resp["result"]["data"] raises a bare TypeError/KeyError with no API message. HuggingFaceEmbeddingFunction and HuggingFaceEmbeddingServer never check the response, so an {"error": ...} body is iterated as keys and fails with could not convert string to float: 'error'.

Fix. Cloudflare: validate result is a dict containing data, otherwise raise RuntimeError with the API errors. HuggingFace (both classes): raise RuntimeError with the API error when the body is a dict.

Test. chromadb/test/ef/test_api_error_responses.py mocks the HTTP session for the three classes (no network or keys); fails before, passes after.

Disclosure: this change was prepared with the assistance of an AI coding agent (Claude).

…e failures

Cloudflare Workers AI: the response check used 'and' and indexed resp['result']
even when absent/None, giving a KeyError/TypeError instead of the API's errors.
HuggingFace: an {"error": ...} JSON body was iterated as embeddings, producing
'could not convert string to float'.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown

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)

This branch has not been deployed

No deployments
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