fix(minimax): map native speech status codes and document TTS - #640
Conversation
MiniMax reports t2a_v2 failures as HTTP 200 with a non-zero base_resp.status_code. Relaying every one as a 502 masked caller mistakes, so map the common codes: rate limits (1002/1039) to 429, authentication (1004) to 401, insufficient balance (1008) to 402, and sensitive input / invalid parameters (1026/2013) to 400. Unknown codes still surface as provider errors, now with the native code in the message. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Add a MiniMax provider page covering setup, temperature clamping, the /v1/audio/speech translation to t2a_v2 (voice IDs, formats, speed range, MINIMAX_MODELS routability), error mapping, and unsupported features. Correct the Audio API page: MiniMax TTS is now natively adapted, and Xiaomi/Cohere translations already were. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe PR adds MiniMax provider documentation and navigation. It maps MiniMax native speech status codes to typed gateway errors and adds table-driven tests for twelve status codes. ChangesMiniMax audio integration
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/providers/minimax/audio_test.go`:
- Around line 181-188: Extend the error-message assertions in the relevant audio
test to verify that gatewayErr.Message also contains
strconv.Itoa(tt.nativeStatus). Keep the existing statusMsg assertion and
status/type checks unchanged.
In `@internal/providers/minimax/audio.go`:
- Around line 156-157: Update the invalid-request branch for statuses 1026 and
2013 in the MiniMax status-mapping function to set the returned GatewayError’s
Provider to "minimax" before returning it. Extend
TestCreateSpeech_MapsNativeStatusCodes to assert this provider attribution while
preserving the existing typed invalid-request error.
- Around line 150-157: Update speechStatusError to handle MiniMax audio codes
2049 and 20132 explicitly: map 2049 to the existing authentication error path
and 20132 to the existing invalid-request error path, preserving the provider
name and message conventions used by neighboring cases instead of falling
through to the default 502 branch.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 30e2cd43-9393-48ab-9b6b-ebf6dc5fd088
📒 Files selected for processing (6)
docs/advanced/audio-api.mdxdocs/docs.jsondocs/providers/minimax.mdxdocs/providers/overview.mdxinternal/providers/minimax/audio.gointernal/providers/minimax/audio_test.go
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Confidence Score: 4/5Not safe to merge until MiniMax invalid-request errors retain their provider attribution. The affected MiniMax request path and the handled-error logging behavior were executed with statuses 1026 and 2013, reproducing the missing provider field. The error classification remains correct, but operational logs lose the upstream source for these failures. Files Needing Attention:
What T-Rex did
Comments Outside Diff (1)
Reviews (1): Last reviewed commit: "docs(minimax): document native TTS and a..." | Re-trigger Greptile |
| case 1008: // insufficient balance | ||
| return core.NewProviderError("minimax", http.StatusPaymentRequired, message, nil) | ||
| case 1026, 2013: // sensitive input content / invalid request parameters | ||
| return core.NewInvalidRequestError(message, nil) |
There was a problem hiding this comment.
Invalid requests lose provider attribution
Native MiniMax status codes 1026 and 2013 are returned through NewInvalidRequestError, whose Provider field is empty. The actual CreateSpeech path returns an empty provider for both statuses, so the handled-error log omits the provider attribute and internal error serialization omits MiniMax attribution. Set Provider to "minimax" before returning this error, consistent with the adjacent status mappings.
Artifacts
Focused MiniMax native-status reproduction test source
- Review-authored test source starts a local MiniMax-shaped HTTP server and invokes the actual CreateSpeech path for statuses 1026 and 2013, showing the provider-attribution path under test.
MiniMax native status output with empty provider
- Executed MiniMax provider test output shows both native statuses 1026 and 2013 return `provider=""`, while public and struct serialization omit provider; the reported defect is reproduced.
Server log provider-attribution contrast test source
- Review-authored server helper test source executes the actual structured logging helper with blank and MiniMax provider values to isolate the externally visible observability effect.
Structured log contrast with and without MiniMax provider
- Executed server logging output shows the blank-Provider current case lacks a provider field and the MiniMax-attributed comparison emits `"provider":"minimax"`; logs are materially affected.
Existing MiniMax native status mapping regression output
- Executed existing MiniMax native-status mapping test passes for all mapped statuses, confirming the focused mapping behavior remains executable after review cleanup.
There was a problem hiding this comment.
Fixed in b051dd7 — Provider = "minimax" is set on the invalid-request branch and asserted in the mapping test.
…bution Handle more codes from MiniMax's official error table: invalid API key (2049) joins 1004 as 401, invalid voice_id/samples (20132) and invisible-character input (1042) join the 400 branch, and rate growth limit (2045) plus usage limit (2056) join the 429 branch. Set Provider on the invalid-request errors so structured logs keep MiniMax attribution, and assert provider plus the native status code in the mapping test. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/providers/minimax/audio_test.go`:
- Around line 151-160: Extend the table-driven cases in the audio error mapping
test with one row for native status 2045 expecting core.ErrorTypeRateLimit and
one row for native status 1042 expecting core.ErrorTypeInvalidRequest. Match the
existing row structure and assert the corresponding HTTP status and
representative messages.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: a3f02afd-b282-4b4e-bcc5-4b798b85f47f
📒 Files selected for processing (2)
internal/providers/minimax/audio.gointernal/providers/minimax/audio_test.go
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Reason: Follow-up to #621 — surface MiniMax speech failures with their real meaning and document the new native TTS support.
Summary
t2a_v2base_resp.status_codevalues to real errors instead of a blanket 502: rate limits (1002/1039) → 429, authentication (1004) → 401, insufficient balance (1008) → 402, sensitive input / invalid parameters (1026/2013) → 400. Unknown codes remain provider errors, now with the native code in the message.docs/providers/minimax.mdx): setup with both regional endpoints, temperature clamping, the/v1/audio/speech→t2a_v2translation (native voice IDs, formats, speed range), theMINIMAX_MODELSroutability note for speech models, and the unsupported list (instructions, transcription, realtime).Provider-specific behavior
base_resp.status_code; clients now see 400/401/402/429 for caller mistakes rather than opaque 502s.t2a_v2needs aGroupIdquery param on international keys, and current speech model IDs.Checks
go test ./internal/...golangci-lint run ./internal/providers/minimax/...mint validate)🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes