fix: handle API error responses in Vertex AI OpenAI-compat endpoint#451
Open
shelvick wants to merge 2 commits intoagentjido:mainfrom
Open
fix: handle API error responses in Vertex AI OpenAI-compat endpoint#451shelvick wants to merge 2 commits intoagentjido:mainfrom
shelvick wants to merge 2 commits intoagentjido:mainfrom
Conversation
…onse When Vertex AI MaaS endpoints return HTTP error responses (e.g. 429, 500), the JSON body contains an "error" key instead of "choices". Without this fix, parse_response passes the error body to the success path, producing a garbage response and losing the error message/status. Add an error-handling clause to OpenAICompat.parse_response/3 that detects error bodies and converts them to ReqLLM.Error.API.Request structs with proper status, reason, and response_body. Update GoogleVertex.decode_response to return the error through Req's pipeline instead of raising. Add a Step.Error clause to preserve API.Request fields when re-processing, preventing double-wrapping that would discard status and response_body.
Vertex AI may wrap the response body in a single-element list. Add a clause to unwrap [body] and delegate to the existing parse_response clauses.
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.
Summary
OpenAICompat.parse_response/3that detects error bodies (%{"error" => _}) and converts them toReqLLM.Error.API.Requeststructs with proper status, reason, and response_bodyGoogleVertex.decode_response/1to return API errors through Req's pipeline ({request, error}) instead of raising, consistent with Azure and Bedrock providersStep.Errorclause forAPI.Requestexceptions that preserves their fields instead of double-wrapping withstatus: nilcode+message), OpenAI-style (message+type), plain string, and unknown structuresTest plan
parse_response/3error handling (Google Cloud format, OpenAI format, string error, unknown structure)