Skip to content

fix(tts): reject non-audio speech synthesis responses - #117345

Merged
steipete merged 3 commits into
openclaw:mainfrom
Yigtwxx:fix/tts-download-binary-validation
Aug 1, 2026
Merged

steipete merged 3 commits into
openclaw:mainfrom
Yigtwxx:fix/tts-download-binary-validation

Conversation

@Yigtwxx

@Yigtwxx Yigtwxx commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Related: #117339
Related: #117227

AI-assisted (Claude Code). I ran every measurement below myself; the mutation runs are reproducible with the commands shown.

What Problem This Solves

Fixes an issue where users generating speech through xAI, Gradium, Azure Speech, or OpenAI would receive a corrupt audio attachment instead of an error when the provider answered with HTTP 200 but a non-audio body.

A successful-status JSON error, an HTML sign-in or captcha page, or a zero-byte response was read straight into the buffer and delivered as playable audio. The user gets a file that will not play, and the provider's actual error message is discarded.

Why This Change Was Made

The repository already owns this contract, and one speech path already uses it: src/tts/openai-compatible-speech-provider.ts:399 reads its audio through readProviderBinaryResponse(..., "audio"). The four affected bundled raw-binary synthesizers were never migrated, so whether a malformed 200 was caught depended on which provider a user routed through — OpenAI-compatible speech was guarded, while native xAI, Gradium, Azure Speech, and OpenAI were not.

This applies the split form (assertProviderBinaryResponseContent + readResponseWithLimit) rather than readProviderBinaryResponse, because the combined helper hardcodes its own onOverflow after spreading caller options and would therefore change each provider's existing byte-cap message. Keeping the split form preserves <Provider> TTS audio response exceeds N bytes exactly as it is today. The same reasoning is why extensions/byteplus and extensions/runway use the split form on the video side.

Cancellation uses void ... .catch(() => undefined) rather than await, matching extensions/google/video-generation-provider.ts:241-243 and src/infra/net/fetch-guard.ts: under debug-proxy capture the body is one branch of a Response.clone() tee, and per src/proxy-capture/runtime.ts:41-46 cancelling such a branch never settles while its sibling is live.

extensions/openai/tts.ts carried the same defect and is now included in a separately attributed maintainer follow-up commit. #117227 changes only the OpenAI video-generation provider and its test, so its file ownership does not overlap the OpenAI TTS owner or test here.

User Impact

A malformed synthesis response now fails with <Provider> TTS API error: malformed audio response instead of producing an unplayable file, and the upstream socket is closed rather than left open until GC.

Evidence

Original contributor validation at historical head 1450696a8f1:

node scripts/run-vitest.mjs \
  extensions/xai/tts.test.ts \
  extensions/gradium/tts.test.ts \
  extensions/azure-speech/tts.test.ts

Tests  31 passed (31)
Tests  23 passed (23)

The added tests are load-bearing, verified by mutation. Reverting only the production files to main turns exactly the new cases red, in two runs (vitest splits these across projects, so they are measured separately):

git stash push -- extensions/xai/tts.ts
→ Tests  4 failed | 27 passed (31)
  × rejects a successful 'JSON error' response as synthesized audio
  × rejects a successful 'problem JSON' response as synthesized audio
  × rejects a successful 'HTML' response as synthesized audio
  × rejects a successful 'empty audio' response as synthesized audio

git stash push -- extensions/gradium/tts.ts extensions/azure-speech/tts.ts
→ Tests  8 failed | 15 passed (23)
  (the same four cases, once for gradium and once for azure-speech)

npx oxlint is clean on all six changed files.

Real behavior proof: a real socket, a real never-ending response, no mocks

Added in 91b601ff667 after the review asked for evidence beyond mocked transports.

extensions/azure-speech/tts.test.ts starts a real node:http server on 127.0.0.1 that answers
200 with content-type: application/json and then never ends the body, then calls the real
azureSpeechTTS against it through endpoint — real global fetch, real SSRF guard, real socket,
no vi.stubGlobal, no provider account. Only the guard differs between the two runs:

source result wall clock
guard removed (current main behaviour) request timed out — synthesis hangs to its deadline with the socket still open 5029 ms
this branch Azure Speech TTS API error: malformed audio response, and the server observes its socket close 120 ms

The close is asserted on the server side (request.socket.once("close", ...) raced against a 250 ms
deadline), so the pass is the operating system reporting the connection gone, not the client claiming
it cancelled.

The same control run also shows the defect's other half in its rawest form. With the guard removed,
the three mocked malformed cases stop throwing and instead resolve:

AssertionError: promise resolved "Buffer[ 123, 34, 101, 114, 114, ... ]" instead of rejecting
AssertionError: promise resolved "Buffer[ 123, 34, 116, 105, 116, ... ]" instead of rejecting
AssertionError: promise resolved "Buffer[ 60, 104, 116, 109, 108, ... ]" instead of rejecting

123, 34, 101, 114, 114 is {"err and 60, 104, 116, 109, 108 is <html — the provider's JSON error
and its HTML sign-in page, handed back as the audio buffer that a channel then delivers as a voice
message.

Command: node scripts/run-vitest.mjs run extensions/azure-speech/tts.test.ts --reporter=verbose

Proof boundary: xAI and Gradium remain covered through their focused provider-owner tests because their provider network/hostname policies intentionally reject loopback. Azure Speech and OpenAI are each covered end to end with real localhost HTTP, real global fetch, their real SSRF guards, and synthetic credentials as detailed below. No hosted provider account was used.

Maintainer complete-owner verification (exact head 97b84c2c8e95b4be937274631708f5d095219c07)

Preserved both original @Yigtwxx commits 1450696a8f1bcc94289c72fea351bf308e4bbca6 and 91b601ff667a6e6beaa8f476451ca09edc34c297 with their exact original author/date; one separately Peter-authored commit adds only extensions/openai/tts.ts and its existing focused test.

Audited all eight bundled TTS owners: ElevenLabs and Fish Audio already use the canonical binary-response contract; Inworld and Volcengine intentionally consume JSON/base64-framed audio rather than raw audio; Azure Speech, Gradium, xAI, and OpenAI are the complete four-owner raw-binary gap fixed here.

Drove actual Azure Speech and OpenAI production owner functions separately against a real node:http localhost server using real global fetch, their actual SSRF guards, actual synthetic credential transmission, and real TCP connections—14 real authenticated HTTP requests per run, no mocked fetch/time/transport. Untouched current main accepted all eight malformed successful responses as supposed audio: JSON, application/problem+json, HTML, and zero-byte audio for each owner. Exact PR head rejects all eight with the owner-specific visible malformed audio response error. Both owners preserve a genuine 204-byte RIFF/WAVE response with audio/wav, the OpenAI SDK's explicitly supported application/octet-stream, and an absent Content-Type; all real sockets are released.

provider        JSON       problem+json  HTML       empty      WAV      octet-stream  missing type
main Azure      accepted   accepted      accepted   accepted   204 B    204 B         204 B
head Azure      rejected   rejected      rejected   rejected   204 B    204 B         204 B
main OpenAI     accepted   accepted      accepted   accepted   204 B    204 B         204 B
head OpenAI     rejected   rejected      rejected   rejected   204 B    204 B         204 B

Focused exact-owner test command:

OPENCLAW_VITEST_FS_MODULE_CACHE_PATH=/private/tmp/openclaw-vitest-s02-117345-tts node scripts/run-vitest.mjs extensions/azure-speech/tts.test.ts extensions/gradium/tts.test.ts extensions/xai/tts.test.ts extensions/openai/tts.test.ts
4 files passed; 77 tests passed (OpenAI 22, xAI 31, Azure/Gradium 24)

The existing Azure never-ending-body test also proves operating-system-observed real upstream socket closure. Existing focused cases preserve provider-specific exact overflow messages, non-2xx HTTP diagnostics, OpenAI debug capture, bounded body reads, and dispatcher release. Cancellation remains fire-and-forget because awaiting one branch of a debug-capture Response.clone() tee can deadlock.

Direct installed official OpenAI SDK openai/src/resources/audio/speech.ts sends Accept: application/octet-stream, marks __binaryResponse: true, and documents MP3/Opus/AAC/FLAC/WAV/PCM; official API contract: https://platform.openai.com/docs/api-reference/audio/createSpeech . Fresh full four-provider Codex Sol xhigh structured review: clean (0.99). Exact-head Workflow Sanity 30722198801: success; full CI attachment tracked separately.

A successful HTTP 200 carrying a JSON error, an HTML sign-in page, or a
zero-byte body was returned as an audio buffer and written out as a playable
attachment. Route the xAI, Gradium, and Azure Speech synthesizers through the
shared binary-response contract that the OpenAI-compatible speech provider
already uses, so the media kind is validated before the body is read and the
unread body is canceled when it is rejected.

Each provider keeps its own overflow wording, so operator-facing messages are
unchanged apart from the new malformed-response rejection.
@Yigtwxx

Yigtwxx commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

The single red here is check-lint, and it is not a lint violation — the runner disappeared mid-run:

[oxlint] shard concurrency 1 (cpus=4, memGB=16)
[oxlint:core] starting
[oxlint:core] still running after 30s
[oxlint:core] still running after 60s
[oxlint:core] still running after 90s
##[error]The runner has received a shutdown signal. This can happen when the runner
service is stopped, or a manually started runner is canceled.
[oxlint] FAILED (exit 143)

No rule is reported and no file is named; exit 143 is SIGTERM. The same job failed identically on #117345's sibling PR (#117339) in a separate workflow run at roughly the same time, so it looks like runner capacity rather than either branch.

Everything else on this head is green (44 success / 0 genuine failures), and I re-checked the two lanes that could plausibly be mine, locally:

node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.extensions.test.json   → exit 0
npx oxlint <the 6 changed files>                                          → exit 0
node scripts/run-vitest.mjs \
  extensions/xai/tts.test.ts extensions/gradium/tts.test.ts extensions/azure-speech/tts.test.ts
  → Tests 31 passed (31) / Tests 23 passed (23)

A rerun should clear it; let me know if you'd rather I push to trigger one.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. labels Aug 1, 2026
@clawsweeper

clawsweeper Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 7:03 PM ET / 23:03 UTC.

ClawSweeper review

What this changes

The PR makes Azure Speech, Gradium, OpenAI, and xAI TTS reject successful non-audio or empty HTTP responses instead of returning corrupt audio buffers.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep this PR open for normal maintainer landing: current main still accepts successful JSON, HTML, and empty bodies as TTS audio in all four affected raw-binary providers, while the branch applies the existing shared response contract at each provider-owned boundary with focused coverage and real-socket proof.

Priority: P2
Reviewed head: 97b84c2c8e95b4be937274631708f5d095219c07

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) The focused patch reuses the established shared contract, covers every identified raw-binary TTS owner, and has strong regression and real-socket proof.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR contains after-fix real localhost HTTP/socket evidence for Azure and OpenAI plus focused provider-owner coverage for xAI and Gradium; the Azure test directly observes the upstream socket closing after rejection.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR contains after-fix real localhost HTTP/socket evidence for Azure and OpenAI plus focused provider-owner coverage for xAI and Gradium; the Azure test directly observes the upstream socket closing after rejection.
Evidence reviewed 6 items Current-main behavior remains vulnerable: All four current-main TTS owners perform only an HTTP-success check before reading the response body, so a successful JSON, text, or zero-byte response can reach the audio return path.
Existing shared contract matches the repair: The shared binary-response contract rejects JSON and text media types and rejects empty bodies; the branch uses its split validation form so each plugin retains its existing provider-specific overflow error text.
Exact branch applies the contract before consuming each body: The PR validates content type, cancels an unread rejected body without awaiting a debug-capture tee, then preserves the existing bounded reader and overflow wording before rejecting zero-byte audio.
Findings None None.
Security None None.

How this fits together

Bundled TTS plugins make authenticated speech requests, validate and consume their provider HTTP responses, then return audio to the agent or channel workflow. This patch acts at the provider response boundary before malformed bytes can be delivered as an audio attachment.

flowchart LR
  A[Speech request] --> B[Bundled TTS provider]
  B --> C[Provider HTTP response]
  C --> D[Status and binary validation]
  D -->|valid nonempty audio| E[Bounded body read]
  D -->|non-audio response| F[Cancel unread body]
  E --> G[Audio returned to caller]
  F --> H[Actionable provider error]
Loading

Before merge

  • Complete next step (P2) - This open PR already owns the complete bounded repair; wait for the exact-head build and lint checks, then perform normal maintainer landing review.
Agent review details

Security

None.

PR surface

Source +54, Tests +174. Total +228 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 4 59 5 +54
Tests 4 174 0 +174
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 233 5 +228

Review metrics

None.

Technical review

Best possible solution:

Merge the consistent provider-owned binary-response validation after the exact-head build and lint checks complete; keep the current shared helper contract and each plugin’s existing overflow wording.

Do we have a high-confidence way to reproduce the issue?

Yes: current main visibly reads successful response bytes after only an HTTP-status check, and the shared binary-response contract establishes the missing rejection behavior. The PR additionally supplies a real localhost socket test for the Azure owner boundary.

Is this the best way to solve the issue?

Yes: applying the existing shared contract at each raw-binary provider owner is the narrowest maintainable repair, retains provider-specific overflow messages, and avoids inventing a parallel abstraction or new configuration surface.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against eb8c22ed13f9.

Labels

Label justifications:

  • P2: The PR fixes corrupt TTS output and discarded provider diagnostics across four bundled provider plugins, with a bounded user-facing blast radius.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR contains after-fix real localhost HTTP/socket evidence for Azure and OpenAI plus focused provider-owner coverage for xAI and Gradium; the Azure test directly observes the upstream socket closing after rejection.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR contains after-fix real localhost HTTP/socket evidence for Azure and OpenAI plus focused provider-owner coverage for xAI and Gradium; the Azure test directly observes the upstream socket closing after rejection.

Evidence

What I checked:

  • Current-main behavior remains vulnerable: All four current-main TTS owners perform only an HTTP-success check before reading the response body, so a successful JSON, text, or zero-byte response can reach the audio return path. (extensions/azure-speech/tts.ts:222, eb8c22ed13f9)
  • Existing shared contract matches the repair: The shared binary-response contract rejects JSON and text media types and rejects empty bodies; the branch uses its split validation form so each plugin retains its existing provider-specific overflow error text. (src/agents/provider-http-errors.ts:405, eb8c22ed13f9)
  • Exact branch applies the contract before consuming each body: The PR validates content type, cancels an unread rejected body without awaiting a debug-capture tee, then preserves the existing bounded reader and overflow wording before rejecting zero-byte audio. (extensions/openai/tts.ts:183, 97b84c2c8e95)
  • Boundary-level proof is present: The Azure test on the PR head uses a real localhost HTTP connection with a never-ending JSON response and asserts that the server observes socket closure after the malformed response is rejected. (extensions/azure-speech/tts.test.ts:257, 97b84c2c8e95)
  • Feature provenance: The original current-main commit introduced all four affected raw response-reader implementations and the shared provider-response helper, establishing the common owner-boundary gap rather than four unrelated regressions. (extensions/openai/tts.ts:183, 9aceb1620d4f)
  • Current-main overlap check: No touched TTS source or test path changed on main after the PR base, so the branch remains a clean targeted repair of the same owner implementations; the reported behind state is not evidence of a source-path regression. (eb8c22ed13f9)

Likely related people:

  • Jesse Merhi: The current raw response-reader paths for all four affected TTS plugins trace to the same source introduction commit. (role: original current-main owner; confidence: high; commits: 9aceb1620d4f; files: extensions/azure-speech/tts.ts, extensions/gradium/tts.ts, extensions/openai/tts.ts)
  • steipete: The exact PR head includes the OpenAI TTS completion commit and a maintainer verification comment covering the four-provider invariant. (role: recent area contributor; confidence: high; commits: 97b84c2c8e95; files: extensions/openai/tts.ts, extensions/openai/tts.test.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (5 earlier review cycles)
  • reviewed 2026-08-01T10:47:13.545Z sha 1450696 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-01T15:05:03.387Z sha 1450696 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-01T15:14:35.679Z sha 1450696 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-01T19:00:19.781Z sha 1450696 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-01T19:38:46.770Z sha 91b601f :: needs maintainer review before merge. :: none

@Yigtwxx

Yigtwxx commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

On the real-behavior gate: I tried to build the same loopback proof I added to the sibling PR (#117339), and I could not get one that is honest for these three owners. Rather than ship a weaker harness and call it real, here is exactly what blocks it and what I think stands in its place.

What worked on the sibling PR. #117339 now carries a real-socket run: a node:http server answers 200 with content-type: application/json and never ends the body, driven through the real download path with the real global fetch and no mocks. Guard removed, the request hangs to its deadline with the socket still open (5018 ms, request timed out); guard present, it is refused in 97 ms and the server observes its socket close. That measures the exact contract this PR applies — assertProviderBinaryResponseContent(..., "audio") is the same helper, one media kind over.

Why the same harness cannot reach these three. Each owner blocks the loopback for a different reason, measured rather than assumed:

owner transport what stops a real local server
xai postJsonRequest → SSRF guard no allowPrivateNetwork in the public signature; 127.0.0.1 is refused with Blocked hostname or private/internal…
gradium fetchWithSsrFGuard rejects the URL before any request: Gradium baseUrl must use https (extensions/gradium/tts.ts:145)
azure-speech fetchWithSsrFGuard endpoint is derived as https://<region>.tts.speech.microsoft.com, so there is no http seam to point at a local port

Unlike downloadXaiVideo in #117339, none of these functions exposes a private-network or injected-fetchFn seam. I also tried pinning DNS to 127.0.0.1 through the repo's own mockPinnedHostnameResolution so the real SSRF policy would still run — gradium then fails the https check above, and xai recurses into Maximum call stack size exceeded. Adding such a seam to production signatures would widen a patch you have already rated 🦞 5/6 with no findings, which seems like the wrong trade.

What I can offer instead. The tests here do drive the real owner functions end to end and assert on real Response objects — what is stubbed is the transport, not the contract. The mutation runs are what make them load-bearing rather than decorative: reverting only the production files turns exactly the new cases red, 4 for xai and 8 for gradium + azure-speech, measured in two separate runs because vitest splits them across projects.

If a live-provider capture is required regardless, that needs xAI, Gradium and Azure Speech credentials plus a way to make each return a successful non-audio body, which I cannot produce from outside. I am happy to add anything reachable that would close this — including a real-TLS loopback if you would accept a self-signed certificate in the test, or a seam if you would rather have one.

Adds a loopback node:http server that answers 200 with a JSON content type
and then never ends the body, driven through the real azureSpeechTTS path
with the real global fetch and no stubbed transport. Without the guard the
synthesis hangs to its timeout with the socket still open; with it the
response is rejected immediately and the server observes the close.
@Yigtwxx

Yigtwxx commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Real behavior proof added in 91b601ff667, and the PR body is updated with it.

extensions/azure-speech/tts.test.ts now drives azureSpeechTTS against a real node:http server on 127.0.0.1 that answers 200 with content-type: application/json and then never ends the body. The request goes through the real global fetch and the real SSRF guard via the endpoint parameter — no vi.stubGlobal, no stubbed transport, no provider account.

source result wall clock
guard removed (current main behaviour) request timed out, socket still open 5029 ms
this branch Azure Speech TTS API error: malformed audio response, server observes the close 120 ms

The close is asserted server-side (request.socket.once("close", ...) raced against a 250 ms deadline), so what passes is the OS reporting the connection gone, not the client claiming it cancelled.

The same control run exposes the other half of the defect. With the guard removed the three mocked malformed cases stop throwing and resolve instead:

AssertionError: promise resolved "Buffer[ 123, 34, 101, 114, 114, ... ]" instead of rejecting
AssertionError: promise resolved "Buffer[ 60, 104, 116, 109, 108, ... ]" instead of rejecting

123, 34, 101, 114, 114 is {"err and 60, 104, 116, 109, 108 is <html — the provider's JSON error and its HTML sign-in page returned as the audio buffer a channel then delivers as a voice message.

Command: node scripts/run-vitest.mjs run extensions/azure-speech/tts.test.ts --reporter=verbose

On the second listed merge risk: the loopback run covers one changed owner end to end with a genuine stream, which is what the cancellation and release path needed. xAI and Gradium keep mocked-fetch coverage and share the identical boundary shape; if you would rather have the same loopback case duplicated for those two, say so and I will add it.

Suites on this head: azure-speech 12 passed, xai + gradium 24 passed. npx oxfmt --check clean.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 1, 2026
@steipete

steipete commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Maintainer exact-head verification: 97b84c2c8e95b4be937274631708f5d095219c07 preserves both original @Yigtwxx commits and adds one separately attributed OpenAI TTS owner/test commit, completing the shared invariant across Azure Speech, Gradium, xAI, and OpenAI.

  • Audited all eight bundled TTS owners: ElevenLabs/Fish Audio already validate raw binary; Inworld/Volcengine intentionally consume JSON/base64, so the four changed providers are the complete vulnerable raw-binary set.
  • Actual Azure + OpenAI production owner end-to-end: real authenticated localhost HTTP, global fetch, SSRF guard, TCP sockets; each owner on untouched main accepted successful JSON, application/problem+json, HTML, and zero-byte replies as audio, while this exact head rejects all eight malformed responses. Genuine 204-byte RIFF/WAVE stays valid for audio/wav, application/octet-stream, and missing Content-Type. Azure's contributor regression additionally proves OS-observed closure of a never-ending upstream socket. xAI/Gradium have provider-owner regression tests, not claimed localhost coverage.
  • OPENCLAW_VITEST_FS_MODULE_CACHE_PATH=/private/tmp/openclaw-vitest-s02-117345-tts node scripts/run-vitest.mjs extensions/azure-speech/tts.test.ts extensions/gradium/tts.test.ts extensions/xai/tts.test.ts extensions/openai/tts.test.ts — 4 files / 77 tests passed; existing exact overflow errors, non-2xx diagnostics, debug capture, and dispatcher release remain covered.
  • Fresh full four-provider .agents/skills/autoreview/scripts/autoreview --mode branch --base origin/main --engine codex --thinking xhigh — Sol xhigh clean (0.99). Official OpenAI SDK explicitly requests application/octet-stream; API contract: https://platform.openai.com/docs/api-reference/audio/createSpeech .

Detailed before/after matrix and provider-proof boundaries are recorded in the updated PR body.

@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 1, 2026
@steipete
steipete merged commit 65d6481 into openclaw:main Aug 1, 2026
99 of 105 checks passed
@steipete

steipete commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 2, 2026
* fix(tts): reject non-audio speech synthesis responses

A successful HTTP 200 carrying a JSON error, an HTML sign-in page, or a
zero-byte body was returned as an audio buffer and written out as a playable
attachment. Route the xAI, Gradium, and Azure Speech synthesizers through the
shared binary-response contract that the OpenAI-compatible speech provider
already uses, so the media kind is validated before the body is read and the
unread body is canceled when it is rejected.

Each provider keeps its own overflow wording, so operator-facing messages are
unchanged apart from the new malformed-response rejection.

* test(azure-speech): prove the audio guard closes a real upstream socket

Adds a loopback node:http server that answers 200 with a JSON content type
and then never ends the body, driven through the real azureSpeechTTS path
with the real global fetch and no stubbed transport. Without the guard the
synthesis hangs to its timeout with the socket still open; with it the
response is rejected immediately and the server observes the close.

* fix(openai): reject malformed binary speech responses

---------

Co-authored-by: Peter Steinberger <[email protected]>
@Yigtwxx
Yigtwxx deleted the fix/tts-download-binary-validation branch August 2, 2026 07:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: gradium extensions: openai extensions: xai P2 Normal backlog priority with limited blast radius. plugin: azure-speech Azure Speech plugin proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants