fix(tts): check HTTP status before parsing MiniMax t2a_v2 response - #38610
Closed
annguyenNous wants to merge 1 commit into
Closed
fix(tts): check HTTP status before parsing MiniMax t2a_v2 response#38610annguyenNous wants to merge 1 commit into
annguyenNous wants to merge 1 commit into
Conversation
Add response.raise_for_status() after the POST call in _generate_minimax_tts(). Without this, HTTP 4xx/5xx responses from MiniMax are passed to response.json() which may raise JSONDecodeError if the error page is HTML rather than JSON. The non-t2a_v2 code path already handles this correctly at line 1299 — this makes both paths consistent.
Collaborator
|
Duplicate of #38142 — identical fix: add |
Contributor
|
Thanks for this @annguyenNous — solid instinct on guarding the HTTP status before JSON parsing. Checking current if is_t2a_v2:
response.raise_for_status() # already here on main
result = response.json()So the fix is already present and your added call would be a duplicate. Closing as already-handled — but the diagnosis was correct, just a tick stale against current main. Appreciate the contribution. |
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
Add
response.raise_for_status()after therequests.post()call in_generate_minimax_tts()to catch HTTP errors before attempting to parse the response as JSON.Bug
When MiniMax TTS API returns HTTP 4xx/5xx (e.g., rate limit, auth failure, server error), the t2a_v2 code path calls
response.json()directly. If the error response is HTML (common for 502/503 from proxies) or non-JSON, this raisesJSONDecodeErrorinstead of a meaningful HTTP error.The non-t2a_v2 code path already handles this correctly at line 1299 (
response.raise_for_status()in the fallback). This fix makes both paths consistent.Fix
Impact
JSONDecodeErrorrequests.HTTPErrorwith status code and message