Repository navigation
fix(media): reject non-binary generated video downloads across providers - #117339
Conversation
|
Codex review: needs maintainer review before merge. Reviewed September 5, 2026, 8:46 AM ET / 12:46 UTC. ClawSweeper reviewWhat this changesThe PR makes generated-media download owners reject JSON, text, and empty responses through the existing binary reader while preserving their timeout and overflow behavior. Merge readiness✅ Ready for maintainer review This remains useful work absent from current main and the inspected release paths. Both prior rank-up moves are addressed, and no blocking introduced defect was found. Priority: P2 Review scores
Verification
How this fits togetherVideo-generation providers submit jobs, retrieve output URLs, and download assets for OpenClaw to save and deliver. These download owners enforce response validity, byte limits, and transport cleanup before returning an asset. flowchart TD
A[Video generation request] --> B[Provider job and output URL]
B --> C[Provider-owned HTTP download]
C --> D{Binary response valid?}
D -->|Yes| E[Bounded read with existing deadlines]
D -->|No| F[Release transport and report error]
E --> G[Generated asset for storage and delivery]
E -->|Limit or timeout| F
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +24, Tests +625. Total +649 across 23 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep validation in the existing download owners using the canonical reader; the additional caller arguments preserve distinct transport, deadline, and overflow contracts without duplicating validation. Do we have a high-confidence way to reproduce the issue? Yes: current source exposes download paths that accept HTTP-200 JSON/text as asset bytes, and the supplied baseline/candidate socket results exercise that failure. This read-only review did not execute a reproduction. Is this the best way to solve the issue? Yes: reusing the existing binary reader fixes the owning boundaries while retaining provider-specific acquisition and cleanup. Changing the reader's global timeout default or restoring inline validators would introduce broader behavior changes or duplication. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 994ae0c76794. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (36 earlier review cycles; latest 8 shown)
|
|
Pushed
Exit 143 is SIGTERM, and no rule ever fired. The same job failed the same way on my other PR (#117345) in a separate workflow run, which is what points at the runner rather than at either branch.
Happy to rebase or push again if a rerun is easier that way. |
|
Follow-up on the two infrastructure reds: both reproduced on the new head (
Two heads, two workflow runs, identical failure modes, and the same Everything else on this head is green (58 success). Flagging rather than chasing it, since re-running from a fork is not something I can trigger. Happy to rebase onto a newer |
|
The remaining P1 is closed in
The URL-only fallback is untouched and still reachable only from the overflow path: the Four regressions added, and they are load-bearing by mutation rather than assertion — same separation I ran for google:
Command: The two guards catch disjoint inputs, so neither is redundant: with only the content-type check the zero-byte
|
|
Refreshed onto
So the defect this PR reports is still open on
The three owners in this PR are exactly the three the refactor left unflagged, so this branch now sets the flag instead of duplicating the guard. That is a -33 line change against the previous head for those files: MiniMax, Together and xAI each lost their hand-written One owner does not fit the flag. The remaining owners in this PR — Comfy, fal video, Google, OpenRouter, Vydra and the shared DashScope-compatible transport — are not callers of Single-variable control, same working tree, produced by restoring only the three provider sources from
All 18 control failures are this PR's cases and nothing else — the four The rest of the PR's surface on the merged head: Windows 11, Node 24.18.1, native run. Two notes on the previous CI state, since the review listed it as a blocker. The five failed gates on Separately, and out of scope here because this PR is about video: |
|
@clawsweeper re-review The reviewed head |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Refreshed the branch and closed the remaining The earlier red wall was inherited, not from this PRThe previous head sat on a stale base. Every one of the 11 failing checks landed outside this PR's file set (
They map one-to-one onto 95ea82b (#120501, Independent confirmation for the lint row: Merging current Consolidated the DashScope matrix (the open P3)The review was right that the added Coverage went up rather than down: the table runs across both provider labels, so the empty-video contract is now asserted for The assertion is load-bearing. Replacing the guard in The debug-capture clone test stays separate, since the tee-hang path is not expressible through the shared table. The one remaining red is a clock-resolution flake
The two timestamps are identical, so the heartbeat renewal landed inside the same millisecond and
I cannot re-run it from a fork ( |
|
Refreshed onto current main and re-measured. New head: Why the refreshThe branch was 1518 commits behind and the only red check was an unrelated flake, so both were worth clearing before a maintainer looks at this.
Measurement at the refreshed headNode 24.15.0, one shard per file.
The right-hand column is the mutation control: the nine production files restored from
The previous red check
Both sides are the same millisecond, so the assertion is a clock-resolution flake rather than a behavioral failure. This PR touches no file under @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
The refreshed head has one red check, The failure is a timeout, not an assertion: This PR touches That alone is only an argument, so here is the control arm — the same single file, same Node 24.15.0, same machine, run twice:
Same test, same failure, on unmodified main. The defect is not introduced by this branch. Worth flagging separately: the timeout is not far-fetched noise. The whole file spends 110s of a 120s budget on current main, so this case sits right at the limit and will fail whenever the runner is slightly slower — the CI shard reported 194.82s of test time for its slice. That looks like a real fragility in The previously reported red ( |
|
Refreshed against The conflict was real and confined to one file, Resulting diff for that file against Measured on the refreshed head, Node 24.18.1:
The PR is mergeable again. |
|
Applied the P1 from the August 19 review — the six owner-local copies of the binary-response lifecycle now delegate to What movedEach owner had repeated the shared reader's whole contract inline: content-type rejection, fire-and-forget cancellation of the rejected body, the bounded read, and the empty-body check. All six now call the shared helper and keep only what is genuinely theirs:
DashScope's precheck stays ahead of the shared reader on purpose: it rejects any non- Error strings are unchanged, because the shared reader composes them from the same Production surfaceThe review metric was RefreshThe branch was 1878 behind and four
Measurement at
|
| arm | vydra suite result |
|---|---|
| consolidated, same 7-file command x3 | 3 passed |
| pre-consolidation control, same command x3 | 3 passed |
| consolidated, solo x3, then x5 under 8 busy cores | 8 passed |
| pre-consolidation control, solo x5 under 8 busy cores | 5 passed |
The mechanism is arm-independent and belongs to main: the guarded request signal and the body read expire on the same absolute deadline, and extensions/vydra/shared.ts:315-321 on origin/main normalizes the resulting race with Date.now() >= deadline.deadlineAtMs. When the process is starved, the guarded abort can settle a moment before Date.now() reaches that mark, so the normalization misses and the raw abort message surfaces. Nothing in the consolidation touches either timer — it moves the same timeoutMs/onTimeout pair through one extra await frame. I am reporting it because I observed it, not because I can attribute it.
|
Exact-head CI on Mine: the shared provider-http mock returns an explicit export list
readProviderBinaryResponse: (
await importActual<typeof import("openclaw/plugin-sdk/provider-http")>()
).readProviderBinaryResponse,I fixed it in the shared helper rather than by importing the reader from Control arm, same file, same machine, only the helper differing:
The residual Everything else that builds on that helper is clean at
Not mine:
|
|
Follow-up on the CI note above, since that run finished after I posted it. Exact-head CI on Corepack could not fetch the pinned pnpm tarball, so the job failed during dependency install. |
|
Refreshed onto Unlike the other branches I refreshed today, Re-measured, Windows 11, Node 24.18.1
Both arms on the same tree; the control arm reverts the nine provider sources and keeps this The third is the one that matters most: with the debug proxy's capture clone still holding the On the red
|
|
Refreshed onto Conflict. One real break from main drift. #130804 made the guarded fetch's release path cancel an unread body, so a rejected download is now cancelled twice — harmless, since Verification on the new head
The mutation control is the part that matters for triage: |
Reuse the shared binary reader across the remaining providers without adding shorter idle deadlines. Reject captured malformed responses before transport release, while preserving overflow handling and generated filenames. Co-authored-by: Yigtwxx <[email protected]>
|
Ready for guarded landing at
Validation used isolated Linux source checkouts at the exact baseline and candidate commits. No paid provider or channel-delivery claim is made. Exact validation commandsnode scripts/run-vitest.mjs src/media-generation/provider-assets.test.ts extensions/vydra/shared.test.ts extensions/xai/video-generation-transport.test.ts
node scripts/run-vitest.mjs extensions/comfy/image-generation-provider.test.ts extensions/comfy/video-generation-provider.test.ts extensions/comfy/music-generation-provider.test.ts extensions/fal/video-generation-provider.test.ts extensions/google/video-generation-provider.test.ts extensions/minimax/video-generation-provider.test.ts extensions/openrouter/video-generation-provider.test.ts extensions/openrouter/video-generation-provider.download.test.ts extensions/together/video-generation-provider.test.ts src/video-generation/dashscope-compatible.test.ts src/agents/provider-http-errors.test.ts extensions/openai/video-generation-provider.test.ts extensions/byteplus/video-generation-provider.test.ts extensions/runway/video-generation-provider.test.ts extensions/qwen/video-generation-provider.test.ts extensions/alibaba/video-generation-provider.test.ts
pnpm build qaRuntime
openclaw infer video generate --agent main --model xai/grok-imagine-video --prompt delayed-valid --output video.mp4 --timeout-ms 45000 --json
ffprobe -v error -show_entries format=duration:stream=codec_name,width,height -of json video.mp4
ffmpeg -hide_banner -loglevel error -i video.mp4 -f null -The CLI commands used the documented provider configuration pointed at the HTTP fixture. Formatter, changed-file lint, max-lines, assertion-safety, media-download helper, and whitespace checks also pass. |
|
Thanks @Yigtwxx! Landed as 9ebaa82502ca, from verified head 24c7fcbc12c. Proof: the built video-generation CLI now rejects malformed output without saving a file, while a complete playable MP4 still saves after a 31-second download pause.
367 focused/sibling tests passed, the 46-test baseline regression control failed as expected, exact-head CI is green, and independent review is clean. Provider fixtures used real HTTP sockets; no authenticated vendor or channel-delivery coverage is claimed. |
Related: #117227.
What Problem This Solves
Fixes an issue where generated-video downloads could return HTTP 200 with JSON, problem JSON, HTML, plain text, or an empty body and still become successful provider assets. Captured responses could also delay malformed-response errors until the request timed out.
Why This Change Was Made
Use the existing
readProviderBinaryResponsecontract in the remaining Google, fal, OpenRouter, Vydra, Comfy, MiniMax, Together, and xAI paths, plus the shared DashScope downloader.Provider-specific transport policy remains with each provider. DashScope keeps its stricter video MIME check. Comfy and Vydra apply the same binary rule to sibling media kinds handled by their shared download owner.
The previous review's timeout finding is addressed: deadline-only callers explicitly disable the binary reader's default idle timer. The shared generated-video helper forwards that existing reader option; previously validated callers retain their current default. No new user configuration is required.
User Impact
Evidence
Baseline:
8deaa18a397fa20b5fa4a2095b41c1708d7a743f.Repair:
24c7fcbc12c3f792290f654e0ea9e32666d1e7f9.Shipped CLI proof
Both exact commits were built with
pnpm build qaRuntime. The realopenclaw infer video generate --agent main --model xai/grok-imagine-video --prompt <scenario> --output <case>/video.mp4 --timeout-ms <budget> --jsoncommand then used the same local HTTP provider fixture.ok: true; savedvideo.json/video.htmlas generated-video outputok: false;xAI generated video download: malformed video response; no output fileThe saved delayed video is a real 2246-byte H.264 MP4: 64×64, 1.000000 seconds.
ffprobereads it and a completeffmpegdecode exits 0. The JSON file saved by main fails video probing. This addresses the independent review's product-entry-point and playable-output gaps without changing the repair code.Downloader and sibling proof
provider-result.mp4application/octet-streamThese are real HTTP socket fixtures, not authenticated provider calls. Vydra, MiniMax, and Comfy use their configured local provider flows. Google, fal, OpenRouter, and Together use a socket-backed request router through their real generation implementations, with real fetch response streams rather than mocked response objects. The shipped CLI proof above additionally covers visible failure/success and output persistence. Remote provider availability and channel delivery are not claimed.
Validation:
The 27-commit contribution was consolidated onto current main. Unnecessary Buffer copies and weaker cancellation assertions were removed. The shipped shared-helper flag remains for existing SDK callers.
Production: +64/-40, net +24. Tests/test support: +629/-4, net +625. The production growth supplies the binary-reader arguments and preserves existing caller-owned deadlines; changing the reader default or restoring inline validators would either change shipped timeout behavior or duplicate the canonical contract.
Original contribution and reproduction by @Yigtwxx. Maintainer repair is AI-assisted.
Separate follow-up: audit fal's image and music download owners for the same binary-response contract; those paths are not changed by this generated-video repair.