fix: propagate API error messages for auto-embeddings with empty/too-long input#187
Open
rtmalikian wants to merge 1 commit into
Open
Conversation
…long input When a remote embedding API (OpenAI, Voyage, Jina) returns an error for empty input or input exceeding the model's token limit, the actual error message from the API was being discarded. Users would see a generic 'HTTP error from remote model: status code 400' instead of the descriptive message like 'maximum context length is 8192 tokens'. Changes: - Add 'message' field to RemoteHttpError variant to carry API error details - Extract error message from API JSON response (error.message for OpenAI/Voyage, error.message or detail for Jina) - Include API error message in displayed error output - Add pre-validation for empty inputs before making API calls across all three remote model implementations (OpenAI, Voyage, Jina) - Add descriptive messages for all RemoteHttpError usages in the success response parsing path Fixes manticoresoftware#143
Collaborator
|
Thanks for the PR @rtmalikian |
donhardman
approved these changes
Jun 20, 2026
Member
|
Hey @rtmalikian Thanks for the PR. Let's fix the conflicts and also formatting with |
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.
What was broken
When a remote embedding API (OpenAI, Voyage, Jina) returned an error for empty input or input exceeding the model's token limit, the actual error message from the API was discarded. Users would see a generic:
Instead of the descriptive message the API actually returned, such as:
The same generic error appeared for empty string inputs (
INSERT INTO test (id, abstract) VALUES (1, '')).What the fix does
1. Pre-validation for empty inputs
All three remote model implementations (OpenAI, Voyage, Jina) now check that at least one non-empty text is provided before making an API call. This avoids unnecessary network round-trips and gives a clear local error message.
2. API error message propagation
Added a
messagefield to theRemoteHttpErrorvariant inLibError. When the API returns an error response with a JSON body containingerror.message(OpenAI/Voyage) orerror.message/detail(Jina), the actual error message is now extracted and included in the displayed error output.3. Descriptive messages for response parsing errors
All
RemoteHttpErrorusages in the success response parsing path now include specific messages (e.g., "response missing 'data' array", "API returned no embeddings in response") instead of just the HTTP status code.Files changed
embeddings/src/error.rs— Addedmessage: Option<String>toRemoteHttpError, updatedDisplayimplementationembeddings/src/model/openai.rs— Pre-validation + error message extractionembeddings/src/model/voyage.rs— Pre-validation + error message extractionembeddings/src/model/jina.rs— Pre-validation + error message extraction (supports botherror.messageanddetailformats)Before
After
For empty input:
Verification
RemoteHttpErroracross the codebase (28 instances across 3 model files)messagefieldRemoteHttpErrordirectly (tests use the error indirectly through model operations)PartialEq,Eq, andHashderives onLibErrorwork correctly withOption<String>About the Author: Raphael Malikian — Clinical AI Solutions Architect. I specialise in building and fixing AI/ML systems for healthcare, including vector databases, RAG pipelines, and clinical NLP. If you need help with your project or think I can add value to your organisation, feel free to reach out — I'd love to connect.
📧 [email protected]
🔗 GitHub: https://github.com/rtmalikian
🔗 LinkedIn: http://www.linkedin.com/in/raphael-t-malikian-mbbs-bsc-hons-71075436a
Disclosure: This code was developed with assistance from mimo-v2.5-pro (Xiaomi) via Hermes Agent (Nous Research). All changes were reviewed, tested against the actual codebase, and verified for correctness.