Repository navigation
fix(embedding): raise API error message for Cloudflare and HuggingFace failures - #7999
Open
pcbeingused333 wants to merge 1 commit into
Open
pcbeingused333 wants to merge 1 commit into
pcbeingused333 wants to merge 1 commit into
Conversation
…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'.
Reviewer ChecklistPlease leverage this checklist to ensure your code review is thorough before approving Testing, Bugs, Errors, Logs, Documentation
System Compatibility
Quality
|
This branch has not been deployed
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cause.
CloudflareWorkersAIEmbeddingFunction.__call__checked"result" not in resp and "data" not in resp["result"]. Withand, a failed response (e.g. wrong key/account:{"success": false, "errors": [...], "result": null}) skips the check, andresp["result"]["data"]raises a bareTypeError/KeyErrorwith no API message.HuggingFaceEmbeddingFunctionandHuggingFaceEmbeddingServernever check the response, so an{"error": ...}body is iterated as keys and fails withcould not convert string to float: 'error'.Fix. Cloudflare: validate
resultis a dict containingdata, otherwise raiseRuntimeErrorwith the APIerrors. HuggingFace (both classes): raiseRuntimeErrorwith the APIerrorwhen the body is a dict.Test.
chromadb/test/ef/test_api_error_responses.pymocks 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).