Skip to content

fix(tts): check HTTP status before parsing MiniMax t2a_v2 response - #38610

Closed
annguyenNous wants to merge 1 commit into
NousResearch:mainfrom
annguyenNous:fix/tts-minimax-status-check
Closed

fix(tts): check HTTP status before parsing MiniMax t2a_v2 response#38610
annguyenNous wants to merge 1 commit into
NousResearch:mainfrom
annguyenNous:fix/tts-minimax-status-check

Conversation

@annguyenNous

Copy link
Copy Markdown
Contributor

Summary

Add response.raise_for_status() after the requests.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 raises JSONDecodeError instead 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

response = requests.post(base_url, json=payload, headers=headers, timeout=60)
response.raise_for_status()  # <-- added

if is_t2a_v2:
    result = response.json()

Impact

  • Before: HTTP errors from MiniMax may cause confusing JSONDecodeError
  • After: HTTP errors raise requests.HTTPError with status code and message

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.
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists tool/tts Text-to-speech and transcription provider/minimax MiniMax (Anthropic transport) labels Jun 4, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #38142 — identical fix: add response.raise_for_status() before response.json() in the MiniMax t2a_v2 TTS path (tools/tts_tool.py) so HTTP 4xx/5xx surface as a clear HTTPError instead of an opaque JSONDecodeError. Note: Nix CI is currently failing on this PR.

@teknium1

teknium1 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Thanks for this @annguyenNous — solid instinct on guarding the HTTP status before JSON parsing.

Checking current main though, the t2a_v2 branch in _generate_minimax_tts() already calls response.raise_for_status() immediately before result = response.json():

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.

@teknium1 teknium1 closed this Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Medium — degraded but workaround exists provider/minimax MiniMax (Anthropic transport) tool/tts Text-to-speech and transcription type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants