Repository navigation
fix(speech)!: download MiniMax URL output only from allowed hosts, query async tasks with GET - #166
Conversation
MiniMax documents the async task query as GET /v1/query/t2a_async_query_v2 with task_id (an int64) as a query parameter: https://platform.minimax.io/docs/api-reference/speech-t2a-async-query The async test pinned a POST with a JSON body; it now expects the documented request and uses the page's example ids. A second test asks for URL output and has the response name a host nobody allowed; it expects the synthesis to fail without the URL being fetched. Both fail on the provider as it stands; the fix follows.
…ery async tasks with GET URL output. With providerSpecificOptions.outputFormat 'url', synthesize() fetched whatever URL the synthesis response returned and returned the body as audio: any scheme, any host (internal addresses included), no status check, no timeout, no size cap. MiniMax documents the link as valid for 24 hours but not the host it uses, so the download now needs an explicit allow: - The link must be https and its host must be listed in the new audioUrlHosts option (an exact name, or *.example.com for subdomains). With no host listed, URL output fails with an error naming the host and nothing is fetched. SpeechRuntime reads the list from MINIMAX_TTS_AUDIO_URL_HOSTS (comma-separated). - The download sends no key, refuses redirects, times out after audioDownloadTimeoutMs (30 s by default), fails on a non-2xx status and stops reading past maxAudioDownloadBytes (100 MiB by default; a declared Content-Length above it is refused before the body is read). Async query. queryAsync() sent POST /v1/query/t2a_async_query_v2 with a JSON body; MiniMax documents GET with task_id, an int64, as a query parameter. It now sends the GET with no body. queryAsync takes a string or a number, and MiniMaxAsyncSpeechResponse.task_id is typed number | string. Vendor documentation: - output_format url, "Returned url is valid for 24 hours" (no host given): https://platform.minimax.io/docs/api-reference/speech-t2a-http - GET /v1/query/t2a_async_query_v2, task_id in query, int64: https://platform.minimax.io/docs/api-reference/speech-t2a-async-query UNVERIFIED, so no host is allowed by default: which host MiniMax's audio links use, and whether they serve without a redirect. BREAKING CHANGE: URL output (providerSpecificOptions.outputFormat 'url') downloads only from hosts listed in audioUrlHosts, or in MINIMAX_TTS_AUDIO_URL_HOSTS through SpeechRuntime; without one, synthesize() throws instead of fetching. MiniMaxAsyncSpeechResponse.task_id is number | string instead of string.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Reviewer's GuideThe MiniMax TTS provider now safely downloads URL-form audio only from configured HTTPS hosts with credential-free, bounded, timeout-controlled requests, while async task polling is corrected to the documented GET/query-parameter API and numeric task IDs are supported; runtime wiring and coverage are updated accordingly. Sequence diagram for secure MiniMax URL audio synthesissequenceDiagram
participant Client
participant Provider as MiniMaxTextToSpeechProvider
participant MiniMax
participant AudioHost
Client->>Provider: synthesize(text, outputFormat=url)
Provider->>MiniMax: Synthesize request
MiniMax-->>Provider: HTTPS audio URL
alt host not in audioUrlHosts
Provider-->>Client: Error with hostname
else allowed HTTPS host
Provider->>AudioHost: fetch(url, redirect=error, signal=timeout)
AudioHost-->>Provider: 2xx response
Provider->>Provider: readCappedBody(maxAudioDownloadBytes)
Provider-->>Client: Audio buffer
end
Sequence diagram for MiniMax async task status querysequenceDiagram
participant Client
participant Provider as MiniMaxTextToSpeechProvider
participant MiniMax
Client->>Provider: queryAsync(taskId: string | number)
Provider->>MiniMax: GET /v1/query/t2a_async_query_v2?task_id=taskId
Note over Provider,MiniMax: Authorization header, no body or Content-Type
MiniMax-->>Provider: Async task status
Provider-->>Client: MiniMaxAsyncSpeechResponse
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (4)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review. 📝 WalkthroughWalkthroughMiniMax TTS now restricts URL audio downloads to configured HTTPS hosts and applies download timeout and byte limits. Async task queries accept numeric or string IDs and send them as GET query parameters. ChangesMiniMax TTS provider
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Bug fix Sequence Diagram(s)sequenceDiagram
participant MiniMaxTextToSpeechProvider
participant MiniMaxAPI
participant AllowedAudioHost
MiniMaxTextToSpeechProvider->>MiniMaxAPI: Send synthesis request
MiniMaxAPI-->>MiniMaxTextToSpeechProvider: Return audio URL
MiniMaxTextToSpeechProvider->>AllowedAudioHost: Fetch permitted HTTPS URL without authorization
AllowedAudioHost-->>MiniMaxTextToSpeechProvider: Return audio response
Merge Risk: ⚪ Minimal · up to This change restricts MiniMax URL audio downloads to configured HTTPS hosts and switches async task queries to GET. No merge-blocking risk was found. Operators must set MINIMAX_TTS_AUDIO_URL_HOSTS before URL output works. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
PR Summary by QodoSecure MiniMax URL audio downloads and correct async task queries
AI Description
Diagram
High-Level Assessment
Files changed (4)
|
Code Review by Qodo
1.
|
MiniMax sends task_id and file_id as int64 JSON numbers (https://platform.minimax.io/docs/api-reference/speech-t2a-async-query). JSON.parse rounds an integer past 2^53, and a rounded task id passed back to queryAsync names another task. The provider now reads its JSON bodies as text and keeps such an id as its decimal string; an id that fits a JavaScript number stays a number, so today's 14-digit ids are unchanged. MiniMaxAsyncSpeechResponse.file_id is typed number | string, as task_id is.
## [0.13.0](v0.12.24...v0.13.0) (2026-10-08) ### ⚠ BREAKING CHANGE * **speech:** URL output (providerSpecificOptions.outputFormat 'url') downloads only from hosts listed in audioUrlHosts, or in MINIMAX_TTS_AUDIO_URL_HOSTS through SpeechRuntime; without one, synthesize() throws instead of fetching. MiniMaxAsyncSpeechResponse.task_id is number | string instead of string, and file_id is number | string instead of number. ### feat * **safety:** a persisted spend meter that processRequest reserves against before any provider call (#167) ([b9c2e91](b9c2e91)) ### fix * **api:** five defects from a cold read of the gmi() session runner (#165) ([5eec49c](5eec49c)) * **speech:** download MiniMax URL output only from allowed hosts, query async tasks with GET (#166) ([14b86bf](14b86bf))
Summary
Two fixes to the MiniMax TTS provider, found in the review of #39.
URL output fetched any URL. With
providerSpecificOptions.outputFormat: 'url',synthesize()fetched whatever URL the synthesis response returned and handed the body back as audio: any scheme, any host (internal addresses included), no status check, no timeout and no size cap. MiniMax documents the link as "valid for 24 hours" but not the host it uses (Synchronous Text to Speech,output_format), so the download now needs an explicit allow:https, and its host must be listed in the newaudioUrlHostsoption: an exact name, or*.example.comfor that domain's subdomains. With no host listed, URL output fails with an error that names the host, and nothing is fetched.SpeechRuntimereads the list fromMINIMAX_TTS_AUDIO_URL_HOSTS(comma-separated).redirect: 'error'), times out afteraudioDownloadTimeoutMs(30 s by default), fails on a non-2xx status and stops reading pastmaxAudioDownloadBytes(100 MiB by default). A declaredContent-Lengthabove the cap is refused before the body is read, and an empty body is an error.The async task query used the wrong request.
queryAsync()sentPOST /v1/query/t2a_async_query_v2with a JSON body. MiniMax documents aGETwithtask_id, an int64, as a query parameter (Query Speech Generation Task Status). It now sends that GET with no body orContent-Type, and the test that pinned the POST pins the documented request, using the page's example ids.queryAsynctakes the id as a string or a number, andMiniMaxAsyncSpeechResponse.task_idis typednumber | string, since the API returns a JSON number.Not changed, and not verified: which host MiniMax's audio links use (so no host is allowed by default), and whether those links serve without a redirect.
Linked issues
Follow-up to #39.
Type of change
How this was verified
CI on this pull request. The first commit (45d7dc9) holds only the two changed tests. It was pushed before this pull request was opened, so CI did not run on it; on the provider before this change both fail by construction: the query test expects a GET to
...t2a_async_query_v2?task_id=95157322514444and the provider sent a POST to the bare path, and the host test expects a rejection with one fetch while the provider fetched the link and returned its body. The second commit holds the fix and the rest of the tests.What the tests cover, with the vendor stubbed:
task_idin the URL and no body; a link on a host that was not allowed is refused without a fetch, as are anhttplink, a host that only starts with an allowed name, and text that is not a URL; a*.example.comentry allows a subdomain and not the bare domain; a download from an allowed host carries noAuthorizationheader, setsredirect: 'error'and a timeout signal; a 403 fails; a body past the cap, read or declared, fails; a download that outlasts the timeout fails.SpeechRuntimewith the globalfetchstubbed:MINIMAX_TTS_AUDIO_URL_HOSTSallows the host, and with it unset nothing is downloaded.Migration notes
providerSpecificOptions.outputFormat: 'url') downloads only from hosts listed inaudioUrlHosts, or inMINIMAX_TTS_AUDIO_URL_HOSTSwhen the provider is built bySpeechRuntime. Without one,synthesize()throws instead of fetching; the error names the host to list. The defaulthexoutput is unchanged.MiniMaxAsyncSpeechResponse.task_idisnumber | stringinstead ofstring.Checklist
!before the colon for a change that breaks users (feat!:orfeat(api)!:).Summary by Sourcery
Harden MiniMax URL output handling and align asynchronous task queries with the documented API.
Bug Fixes:
Enhancements:
Tests:
Summary by CodeRabbit