Skip to content

fix(media): reject non-binary generated video downloads across providers - #117339

Merged
obviyus merged 1 commit into
openclaw:mainfrom
Yigtwxx:fix/video-download-binary-validation
Sep 5, 2026
Merged

obviyus merged 1 commit into
openclaw:mainfrom
Yigtwxx:fix/video-download-binary-validation

Conversation

@Yigtwxx

@Yigtwxx Yigtwxx commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

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 readProviderBinaryResponse contract 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

  • Malformed downloads produce a provider-labelled error instead of corrupt asset bytes.
  • Unread captured responses do not delay rejection or transport release.
  • Existing overall and idle deadlines, overflow messages, filenames, MIME defaults, and URL-only overflow delivery remain intact.
  • Valid downloads can still pause for more than 30 seconds where the provider's existing deadline allows it.

Evidence

Baseline: 8deaa18a397fa20b5fa4a2095b41c1708d7a743f.
Repair: 24c7fcbc12c3f792290f654e0ea9e32666d1e7f9.

Shipped CLI proof

Both exact commits were built with pnpm build qaRuntime. The real openclaw infer video generate --agent main --model xai/grok-imagine-video --prompt <scenario> --output <case>/video.mp4 --timeout-ms <budget> --json command then used the same local HTTP provider fixture.

Command outcome Main Repair
JSON error / HTML page Exit 0, ok: true; saved video.json / video.html as generated-video output Exit 1, ok: false; xAI generated video download: malformed video response; no output file
Empty body Generic empty-buffer error Provider-labelled malformed-response error
Held JSON response Request timeout Malformed-response error before the provider deadline
Valid MP4 with a 31-second pause Exit 0; saved the complete video Exit 0; saved the identical complete video

The saved delayed video is a real 2246-byte H.264 MP4: 64×64, 1.000000 seconds. ffprobe reads it and a complete ffmpeg decode 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

Scenario Current-main control Repair
HTTP-200 JSON, problem JSON, HTML, text, empty bodies Returned as assets at affected download boundaries Provider-labelled malformed-response error
xAI, Vydra, DashScope: held JSON with an unread response clone Timeout or delayed rejection around 1.5 seconds Rejected in 7–22 ms; server observed socket closure before fixture cleanup
Valid binary body with a 31-second pause Successful in xAI, Vydra, and MiniMax URL/file controls Successful for those paths, OpenRouter, and Together
MiniMax metadata filename provider-result.mp4 Preserved
Comfy missing content type application/octet-stream Preserved

These 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:

  • Focused and sibling suites: 367 passing tests across the shared readers, changed provider owners, Comfy image/music, OpenAI, BytePlus, Runway, Qwen, and Alibaba.
  • Candidate socket matrices: all malformed responses rejected; successful binary controls preserved.
  • The same regression tests against unchanged baseline production fail at the affected boundaries.
  • Added deterministic regression coverage for a valid body pausing beyond the default 30-second idle timer.
  • Pinned formatter, changed-file lint, max-lines, assertion-safety, and media-download helper checks pass.
  • Exact-head CI and independent review are required before landing.

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.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. labels Aug 1, 2026
@clawsweeper

clawsweeper Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 5, 2026, 8:46 AM ET / 12:46 UTC.

ClawSweeper review

What this changes

The 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
Reviewed head: 24c7fcbc12c3f792290f654e0ea9e32666d1e7f9

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent shared-reader repair with relevant socket proof, preserved caller contracts, and both prior rank-up moves addressed.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The pinned body records production download owners using real HTTP streams, prompt malformed-response rejection with server-observed socket closure, and successful 31-second binary pauses after the fix. This sufficiently covers the internal download boundary without claiming authenticated vendor or channel coverage.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The pinned body records production download owners using real HTTP streams, prompt malformed-response rejection with server-observed socket closure, and successful 31-second binary pauses after the fix. This sufficiently covers the internal download boundary without claiming authenticated vendor or channel coverage.
Evidence reviewed 10 items Pinned patch ownership: The complete local merge-base-to-head diff matches the supplied introduced file set. The inspected test merge has the pinned base followed by the exact PR head as parents; its comparison preserves the same scoped changes.
Still necessary on main and release: Current main retains the unvalidated xAI helper call and the conditional shared reader. Both files have identical blobs in v2026.9.1 and fetched main. The comparison from the pinned baseline to fetched main also showed no changes in the ten production files modified by this PR.
Prior timeout finding resolved: Seven deadline-only call sites now explicitly pass chunkTimeoutMs: 0; the shared helper forwards it. Google, Comfy, and DashScope retain their existing idle limits. The canonical reader uses nullish defaulting, so zero disables its added idle timer without changing previously validated callers.
Findings None None.
Security None None.

How this fits together

Video-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
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +24, Tests +625. Total +649 across 23 files.

View PR surface stats
Area Files Added Removed Net
Source 10 64 40 +24
Tests 13 629 4 +625
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 23 693 44 +649

Review metrics

Metric Value Why it matters
Production versus test growth Production net +24; tests and test support net +625 Production growth supplies canonical-reader arguments and preserves provider-owned contracts; it adds no separate validation implementation.
Timeout compatibility 7 explicit idle-disable call sites; 3 existing idle policies retained The revised calls resolve the previous review's unintended 30-second timeout regression.
Configuration surface 1 optional private-local helper argument added; 0 user configuration options Existing callers retain their defaults while newly validated callers can preserve deadline-only reads.

Technical review

Best 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.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The pinned body records production download owners using real HTTP streams, prompt malformed-response rejection with server-observed socket closure, and successful 31-second binary pauses after the fix. This sufficiently covers the internal download boundary without claiming authenticated vendor or channel coverage.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove merge-risk: 🚨 compatibility: Current PR review selected no merge-risk labels.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This repairs malformed generated-media downloads across established providers without evidence of an urgent core outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The pinned body records production download owners using real HTTP streams, prompt malformed-response rejection with server-observed socket closure, and successful 31-second binary pauses after the fix. This sufficiently covers the internal download boundary without claiming authenticated vendor or channel coverage.
  • proof: sufficient: Contributor real behavior proof is sufficient. The pinned body records production download owners using real HTTP streams, prompt malformed-response rejection with server-observed socket closure, and successful 31-second binary pauses after the fix. This sufficiently covers the internal download boundary without claiming authenticated vendor or channel coverage.

Evidence

What I checked:

  • Pinned patch ownership: The complete local merge-base-to-head diff matches the supplied introduced file set. The inspected test merge has the pinned base followed by the exact PR head as parents; its comparison preserves the same scoped changes. (aed04fa53ce1)
  • Still necessary on main and release: Current main retains the unvalidated xAI helper call and the conditional shared reader. Both files have identical blobs in v2026.9.1 and fetched main. The comparison from the pinned baseline to fetched main also showed no changes in the ten production files modified by this PR. (extensions/xai/video-generation-transport.ts:72, 994ae0c76794)
  • Prior timeout finding resolved: Seven deadline-only call sites now explicitly pass chunkTimeoutMs: 0; the shared helper forwards it. Google, Comfy, and DashScope retain their existing idle limits. The canonical reader uses nullish defaulting, so zero disables its added idle timer without changing previously validated callers. (src/media-generation/provider-assets.ts:69, 24c7fcbc12c3)
  • Canonical reader and regression coverage: The existing binary reader rejects text/JSON before consumption, cancels without awaiting a retained tee, rejects empty bytes, and returns Buffer directly. Added Vydra and shared-helper regressions exercise a 31-second pause; existing reader tests retain the default 30-second timeout contract. (src/agents/provider-http-errors.ts:500, 24c7fcbc12c3)
  • Caller, transport, and sibling boundaries: The video tool calls the generation runtime, which invokes provider generation and records failures for existing fallback handling. Provider acquisition, credential forwarding, SSRF policy, and release remain unchanged. OpenAI, BytePlus, and Runway already use validated downloads; fal and OpenRouter retain overflow-only URL delivery. The PR explicitly records fal image/music auditing as separate follow-up work. (src/video-generation/runtime.ts:322, 24c7fcbc12c3)
  • Recorded after-fix socket proof: The captured body, sourceRevision 76dc2e6e2a75d182125e81f4995db45ae9df08f43d185b57889c29fa2e52246a, identifies baseline 8deaa18 and candidate 24c7fcb. It reports real HTTP streams through production download owners: malformed bodies rejected, retained-clone failures returned in 7–22 ms with server-observed socket closure, and valid 31-second pauses completed. Configured local flows and socket-backed generation routers are distinguished from authenticated vendor calls. The reported 367 passing focused/sibling tests are supplemental; this reviewer did not rerun target code. (24c7fcbc12c3)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Yigtwxx: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (36 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-14T16:13:38.322Z sha 007dddfdfe4000278803885c523e71882507c34e :: needs maintainer review before merge. :: none
  • reviewed August 15, 2026, 5:55 PM ET / 21:55 UTC sha unknown :: needs maintainer review before merge. :: none
  • reviewed 2026-08-19T04:08:56.083Z sha 007dddfdfe4000278803885c523e71882507c34e :: needs changes before merge. :: [P1] Use the shared binary reader for the remaining owner paths
  • reviewed 2026-08-19T15:09:33.270Z sha f165d6f484d6d3420c17377e7373254dfb46316e :: needs maintainer review before merge. :: none
  • reviewed 2026-08-19T18:18:15.406Z sha 8a4bbfc8528c109bb5ffbf78f839448edccdc47a :: needs maintainer review before merge. :: none
  • reviewed 2026-08-24T15:09:05.721Z sha 5dbf7ac3d5da982abf15aee59e45e95e6352b5a6 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-28T13:57:21.090Z sha 89c31cee54388a781d1a1c6373398c7bf1c3b836 :: needs maintainer review before merge. :: none
  • reviewed September 5, 2026, 4:04 AM ET / 08:04 UTC sha unknown :: blocked before merge. :: [P1] Preserve existing deadlines when enabling binary validation

@Yigtwxx

Yigtwxx commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Pushed 66ab44e for the check-test-types failure — that one was mine, and the other two reds on the previous head are not.

check-test-types (real, fixed). The new xai transport test omitted allowPrivateNetwork, which XaiVideoRequestPolicy marks as required, so it failed TS2345 even though the suite itself passed. Local oxlint does not type-check, which is how I missed it. Verified the fix with the repo's own checker rather than the suite:

node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.extensions.test.json   → exit 0
node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.json         → exit 0
node scripts/run-vitest.mjs extensions/xai/video-generation-transport.test.ts → Tests 6 passed (6)

check-lint (infrastructure). The job did not report a lint violation; the runner went away mid-run:

[oxlint:core] starting
[oxlint:core] still running after 30s
[oxlint:core] still running after 60s
##[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)

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.

checks-node-compact-small-2 (infrastructure). It died in the core-runtime-tui-pty shard, which produced no output for 610s and was killed:

[shard:core-runtime-tui-pty] [vitest] no output for 300000ms; terminating stalled Vitest process group
[shard:core-runtime-tui-pty] [vitest] process group still alive after 5000ms; sending SIGKILL
[shard:core-runtime-tui-pty] [test] failed 0 Vitest shards in 610.92s
end (exit 143)

failed 0 Vitest shards — nothing asserted false, the process stalled. This branch touches seven provider download paths and their tests; it does not touch the TUI, the PTY layer, or anything that suite loads.

Happy to rebase or push again if a rerun is easier that way.

@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: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 1, 2026
@Yigtwxx

Yigtwxx commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Follow-up on the two infrastructure reds: both reproduced on the new head (c36298a) with the same signatures, so they are not flakes that a rerun clears.

  • check-lint — again The runner has received a shutdown signal, exit 143, with oxlint:core still mid-run. No rule, no file, nothing evaluated.
  • checks-node-compact-small-2 — again the core-runtime-tui-pty shard producing no output until the 300s watchdog kills it, ending failed 0 Vitest shards.

Two heads, two workflow runs, identical failure modes, and the same check-lint behaviour on my other PR (#117345) — that pattern points at the lane rather than at this branch, which touches provider download paths and their tests and loads neither the TUI nor the PTY layer.

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 main if that would pick up a fix on those lanes.

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. and removed 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. labels Aug 1, 2026
@Yigtwxx

Yigtwxx commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

The remaining P1 is closed in 4c8124ad118: downloadOpenRouterVideo now carries the same split contract as the other eight call sites.

extensions/openrouter/video-generation-provider.ts:390-396 previously went straight from the status check to the bounded read, so a successful application/json, *+json, text/*, or zero-byte body became a video/mp4 attachment. It now validates the media kind before the body is read, cancels the rejected body with the same non-awaited void ... .catch(() => undefined) form used elsewhere in this branch, and rejects an empty buffer after the read.

The URL-only fallback is untouched and still reachable only from the overflow path: the deliveryUrl return sits inside the catch guarded by exceededMaxBytes, so a malformed body throws rather than silently degrading to a URL-only asset. The existing returns unsigned URL-only videos when downloads exceed the configured media cap case still passes, which pins that.

Four regressions added, and they are load-bearing by mutation rather than assertion — same separation I ran for google:

source under test result
branch head Tests 26 passed (26)
content-type guard removed Tests 3 failed, 23 passed — JSON error, problem JSON, HTML
empty-buffer check removed Tests 1 failed, 25 passed — empty video

Command: node scripts/run-vitest.mjs run extensions/openrouter/video-generation-provider.test.ts

The two guards catch disjoint inputs, so neither is redundant: with only the content-type check the zero-byte video/mp4 response still passes through, and with only the empty check the JSON and HTML bodies do.

npx oxfmt --check and git diff --check are clean on both changed files. The PR body is updated with the new coverage count (9 call sites across 8 files).

@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 1, 2026
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 7, 2026
@Yigtwxx

Yigtwxx commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

Refreshed onto main at 52f399389f4, and the merge changed the shape of the patch rather than just its base.

bc0c3fcd634 (refactor(providers): shared generated-media download guard and binary-response adoption, #120351) landed while this PR was open. It moved every video owner onto downloadGeneratedVideoAsset in src/media-generation/provider-assets.ts and gave that helper a validateBinaryResponse opt-in that routes the body through readProviderBinaryResponse — the same content-type assertion, fire-and-forget body.cancel(), and empty-body rejection this PR was applying by hand. It also set the flag for the three owners whose fixes had already merged.

So the defect this PR reports is still open on main, but the canonical repair is now a flag, not owner-local code:

shared-helper caller validateBinaryResponse on main
extensions/byteplus/video-generation-provider.ts:193 true (merged #117281)
extensions/runway/video-generation-provider.ts:314 true (merged #117281)
extensions/openai/video-generation-provider.ts:251 true (merged #117227)
extensions/minimax/video-generation-provider.ts:264 absent
extensions/together/video-generation-provider.ts:140 absent
extensions/xai/video-generation-transport.ts:72 absent

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 assertProviderBinaryResponseContent + cancel + empty-length block and gained one line.

One owner does not fit the flag. downloadVideoFromFileId in extensions/minimax/video-generation-provider.ts:287 is a second MiniMax download route that is deliberately not on the shared helper, because it derives fileName from the /v1/files/retrieve metadata rather than from the URL. It reads through readProviderBinaryResponse directly (video-generation-provider.ts:358), the same call the shared helper makes, so both MiniMax routes now enforce the identical contract. extensions/minimax/provider-http.test-helpers.ts passes that symbol through its openclaw/plugin-sdk/provider-http mock, which is why one line there changed too.

The remaining owners in this PR — Comfy, fal video, Google, OpenRouter, Vydra and the shared DashScope-compatible transport — are not callers of downloadGeneratedVideoAsset, so their owner-local validation is unchanged by the refactor and unchanged in this branch.

Single-variable control, same working tree, produced by restoring only the three provider sources from origin/main and re-running the three suites:

arm tests
control — MiniMax/Together/xAI sources from main 18 failed / 23 passed (41)
this branch 52f399389f4 41 passed (41)
$ node node_modules/vitest/vitest.mjs run \
    --config test/vitest/vitest.extension-providers.config.ts \
    extensions/minimax/video-generation-provider.test.ts \
    extensions/together/video-generation-provider.test.ts \
    extensions/xai/video-generation-transport.test.ts

 Test Files  3 passed (3)
      Tests  41 passed (41)

All 18 control failures are this PR's cases and nothing else — the four JSON error / problem JSON / HTML / empty video rejections at each of MiniMax URL, MiniMax file_id, Together and xAI, plus the two xAI transport cases that observe the unread body being cancelled and the upstream socket closing over a real loopback connection.

The rest of the PR's surface on the merged head:

extensions/comfy/ extensions/fal/ extensions/google/video-generation-provider.test.ts
extensions/openrouter/video-generation-provider.download.test.ts extensions/vydra/shared.test.ts
                                                          87 passed (87)
src/video-generation/dashscope-compatible.test.ts
src/media-generation/provider-assets.test.ts              38 passed (38)

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 cbd76215e1f were one infrastructure window, not a code signal. Every one of them failed before reaching a repo check: actionlint — error: RPC failed; HTTP 429; build-artifacts — Base commit still unavailable after fetch attempts: bb612cbe4c1; check-guards and checks-fast-max-lines-ratchet — both exit code 124, the step timeout, during pnpm install. All four started between 06:00:29 and 06:00:48 UTC on August 7 in the same run batch. The new head reruns them from scratch.

Separately, and out of scope here because this PR is about video: extensions/fal/music-generation-provider.ts:161 is the one remaining downloadGeneratedMusicAsset caller without validateBinaryResponse, while extensions/minimax/music-generation-provider.ts:99 has it. Flagging it rather than folding it in, since it needs its own coverage.

@Yigtwxx

Yigtwxx commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The reviewed head cbd76215e1f is superseded by 52f399389f4. bc0c3fcd634 (#120351) landed the shared downloadGeneratedVideoAsset helper with a validateBinaryResponse opt-in, so the three owners this PR targets now adopt that flag instead of carrying owner-local validation, and the previous exact-head CI failures were an infrastructure window (429 / fetch / two exit 124 timeouts) that this head reruns. Details and the control measurement are in the comment above.

@clawsweeper

clawsweeper Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@Yigtwxx

Yigtwxx commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

Refreshed the branch and closed the remaining Before merge item. Head is now d111a15afea.

The earlier red wall was inherited, not from this PR

The previous head sat on a stale base. Every one of the 11 failing checks landed outside this PR's file set (extensions/{comfy,fal,google,minimax,openrouter,together,vydra,xai} and src/video-generation/):

Failing check File that actually failed
check-lint extensions/qa-lab/src/suite-runtime-agent-process.ts — max-lines (707)
checks-node-compact-large-1 src/agents/embedded-agent-runner/run.attempt-normalization.direct.test.ts
checks-node-compact-large-2 / -7, small-9 / -11 src/auto-reply/reply/*
checks-node-compact-small-10 src/commands/sessions.test.ts
check-plugin-sdk-api-baseline, checks-fast-bundled-protocol baseline/setup, inherited

They map one-to-one onto 95ea82b (#120501, fix(ci): restore deterministic main checks), which had already landed on main: align freshness regression fixtures, format context usage fixture, preserve stale total expectation, prepare max-lines base during checkout, stabilize session catalog baseline.

Independent confirmation for the lint row: extensions/qa-lab/src/suite-runtime-agent-process.ts was 719 lines at the old merge base and 433 lines on main.

Merging current main resolved all of them with no conflicts. The patch itself is unchanged at 20 files, +721/-27.

Consolidated the DashScope matrix (the open P3)

The review was right that the added it.each block repeated the JSON, problem-JSON, and HTML rows already covered by the shared invalidGeneratedVideos table. Its only genuinely new row, the empty video/mp4 body, moved into that table and the duplicate block is gone.

Coverage went up rather than down: the table runs across both provider labels, so the empty-video contract is now asserted for Qwen as well as Alibaba Wan.

✓ rejects 'Qwen' 'empty video' responses instead of returning a video
✓ rejects 'Alibaba Wan' 'empty video' responses instead of returning a video
Tests  34 passed (34)

The assertion is load-bearing. Replacing the guard in src/video-generation/dashscope-compatible.ts with if (false) fails exactly those two cases and nothing else:

Tests  2 failed | 32 passed (34)

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

checks-node-compact-large-8 fails in src/skills/lifecycle/upload-store.test.ts:723:

AssertionError: expected 1786189095474 to be greater than 1786189095474

The two timestamps are identical, so the heartbeat renewal landed inside the same millisecond and toBeGreaterThan cannot hold. Supporting evidence that it is unrelated to this branch:

  • this PR touches 0 files under src/skills/;
  • the same shard passed on the two previous runs of this same branch (jobs 93074626821 and 93095315231);
  • sampling the last 25 completed pull-request runs of the CI workflow, checks-node-compact-large-8 was 12 success / 0 failure on other branches.

I cannot re-run it from a fork (rerun-failed-jobs returns HTTP 403, admin rights required) and I would rather not push an empty commit just to reset it. Happy to push a rebase if a fully green rollup is wanted before merge.

@Yigtwxx

Yigtwxx commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

Refreshed onto current main and re-measured. New head: 1005df7a639.

Why the refresh

The 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.

git merge origin/main reported no conflicts, but a clean merge did not mean a working tree. #122636 (refactor(plugins): remove media test globals) deleted the comfy fetch-guard test global, and three of this PR's cases still called it:

ReferenceError: setComfyFetchGuardForTesting is not defined
  extensions/comfy/image-generation-provider.test.ts  Tests  2 failed | 32 passed (34)
  extensions/comfy/video-generation-provider.test.ts  Tests  5 failed |  9 passed (14)

pnpm typecheck stayed at exit 0 through this, because the removed seam was a runtime global rather than a typed export. The fix is a deletion: the module-level vi.mock("openclaw/plugin-sdk/ssrf-runtime") that main now uses already installs fetchWithSsrFGuardMock for these cases, so the explicit calls were redundant (1005df7a639).

Measurement at the refreshed head

Node 24.15.0, one shard per file.

Suite Refreshed head Sources reverted to origin/main
extensions/comfy/image-generation-provider.test.ts 34 passed (34) 2 failed | 32 passed
extensions/comfy/video-generation-provider.test.ts 14 passed (14) 5 failed | 9 passed
extensions/fal/video-generation-provider.test.ts 23 passed (23) 5 failed | 18 passed
extensions/google/video-generation-provider.test.ts 29 passed (29) 4 failed | 25 passed
extensions/minimax/video-generation-provider.test.ts 15 passed (15) 8 failed | 7 passed
extensions/openrouter/video-generation-provider.download.test.ts 4 passed (4) 4 failed (4)
extensions/together/video-generation-provider.test.ts 19 passed (19) 4 failed | 15 passed
extensions/vydra/shared.test.ts 12 passed (12) 5 failed | 7 passed
extensions/xai/video-generation-transport.test.ts 7 passed (7) 6 failed | 1 passed
src/video-generation/dashscope-compatible.test.ts 34 passed (34) 3 failed | 31 passed
Total 191 passed 46 failed

The right-hand column is the mutation control: the nine production files restored from origin/main with the tests left in place. Every one of the ten suites goes red, so the defect is still present on current main and each added case is load-bearing rather than decorative.

pnpm typecheck exits 0 on the refreshed head.

The previous red check

checks-node-compact-large-8 failed on src/skills/lifecycle/upload-store.test.ts:723:

AssertionError: expected 1786189095474 to be greater than 1786189095474

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 src/skills, and the same guard still reads toBeGreaterThan on current main, so the flake is inherited. Re-running it is why the refresh was pushed rather than left alone.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@Yigtwxx

Yigtwxx commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

The refreshed head has one red check, checks-node-compact-small-8. It is inherited from main, measured rather than assumed.

The failure is a timeout, not an assertion:

::error file=src/commands/channels.add.test.ts,
  title=[commands] channelsAddCommand > rejects 'telegram' --use-env when declared env vars are missing,
  line=541::Error: Test timed out in 120000ms.

This PR touches extensions/** and src/video-generation/; git diff --name-only origin/main...HEAD | grep '^src/commands' returns nothing, so the file sets do not intersect.

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:

Tree Result tests time
This PR, head 1005df7a639 1 failed | 31 passed (32) 150.77s
Bare origin/main, 16540e2b885 1 failed | 31 passed (32) 110.25s

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 channels.add.test.ts rather than a one-off, but it belongs to src/commands and is out of scope here.

The previously reported red (checks-node-compact-large-8, upload-store.test.ts:723) is gone on this run.

@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 12, 2026
@Yigtwxx

Yigtwxx commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

Refreshed against main (f329a9489f3); the branch was reported as conflicting.

The conflict was real and confined to one file, extensions/vydra/shared.test.ts. main removed
the does not bound a dripping body when only chunk idle timeout is used negative control together
with its readResponseWithLimit import, while this branch had added two cases immediately above it.
I took main's deletion rather than restoring the test: the import it depended on is gone from
main's copy of the file, so keeping the case would have re-added a dependency main deliberately
dropped. The two cases this PR contributes are unchanged.

Resulting diff for that file against main is additive only:

git diff origin/main -- extensions/vydra/shared.test.ts
  1 file changed, 36 insertions(+)

Measured on the refreshed head, Node 24.18.1:

node scripts/run-vitest.mjs extensions/vydra/shared.test.ts
  Test Files  1 passed (1)
       Tests  11 passed (11)

node scripts/run-vitest.mjs src/video-generation/dashscope-compatible.test.ts
  Test Files  1 passed (1)
       Tests  34 passed (34)
  • ./node_modules/.bin/tsgo -p test/tsconfig/tsconfig.extensions.test.json --noEmit -> exit 0
  • ./node_modules/.bin/tsgo -p test/tsconfig/tsconfig.core.test.json --noEmit -> exit 0
  • ./node_modules/.bin/oxlint extensions/vydra/shared.ts extensions/vydra/shared.test.ts -> exit 0
  • ./node_modules/.bin/oxfmt --check extensions/vydra/shared.test.ts -> exit 0

The PR is mergeable again.

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 13, 2026
@Yigtwxx

Yigtwxx commented Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

Applied the P1 from the August 19 review — the six owner-local copies of the binary-response lifecycle now delegate to readProviderBinaryResponse — and refreshed onto current main. New head f165d6f484d.

What moved

Each 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:

owner retained locally
Comfy workflow-runtime.ts status check, application/octet-stream mime default, per-capability kind
fal exceededMaxBytes flag and the URL-only overflow fallback
Google non-ok branch with its own cancel, mime/filename resolution
OpenRouter exceededMaxBytes flag and the deliveryUrl overflow fallback
Vydra assertOkOrThrowHttpError body timeout, per-kind mime defaults, the outer deadline normalization
DashScope the stricter MIME-kind precheck, which rejects more than the shared header check does

DashScope's precheck stays ahead of the shared reader on purpose: it rejects any non-octet-stream type whose kindFromMime is not video, which is a superset of the shared application/json / +json / text/* rule. Its cancel(error) reason is preserved there too.

Error strings are unchanged, because the shared reader composes them from the same label/kind pair each owner already passed: ${label}: malformed ${kind} response for both header rejection and empty bodies, and every custom onOverflow / onIdleTimeout / onTimeout callback is forwarded verbatim. The Buffer.from(await readProviderBinaryResponse(...)) shape matches the canonical sibling at src/media-generation/provider-assets.ts:73.

Production surface

The review metric was production +100/-24; the consolidation commit alone is +69/-114 over those six files, so the PR's production delta drops from net +77 to net +31:

git show --stat 096bd95310f
  6 files changed, 69 insertions(+), 114 deletions(-)

git diff --stat origin/main...HEAD
  20 files changed, 689 insertions(+), 63 deletions(-)   # production 9 files, +91/-60

Refresh

The branch was 1878 behind and four main commits intersected its files — c97b8ffdfc8 (consolidate meeting and media provider families), 0e3a3aa203b, 56fb860270a, and 568b920b210 (enforce import ordering and deduplication). I checked whether the consolidation had already happened upstream before rebuilding it here; it has not. On origin/main all six owners still read the body straight after the status check:

owner on main line
extensions/comfy/workflow-runtime.ts 589 await readResponseWithLimit(...)
extensions/fal/video-generation-provider.ts 212
extensions/google/video-generation-provider.ts 249
extensions/openrouter/video-generation-provider.ts 393
extensions/vydra/shared.ts 301
src/video-generation/dashscope-compatible.ts 652

git merge origin/main conflicted in one file, extensions/vydra/shared.ts, and only in the import list — main added postJsonRequest and readProviderJsonResponse where this branch added readProviderBinaryResponse. Resolved by keeping all three in the order #124730's new lint rule requires. The branch is now level with main (git rev-list --count HEAD..origin/main -> 0).

Measurement at f165d6f484d

Node 22.23.2 (the review runner's pnpm bootstrap failure is environmental; these were run locally).

node scripts/run-vitest.mjs \
  extensions/comfy/video-generation-provider.test.ts \
  extensions/comfy/image-generation-provider.test.ts \
  extensions/fal/video-generation-provider.test.ts \
  extensions/google/video-generation-provider.test.ts \
  extensions/openrouter/video-generation-provider.download.test.ts \
  extensions/vydra/shared.test.ts \
  src/video-generation/dashscope-compatible.test.ts
  Test Files  7 passed (7)
       Tests  149 passed (149)

node scripts/run-vitest.mjs \
  extensions/xai/video-generation-transport.test.ts \
  extensions/minimax/video-generation-provider.test.ts \
  extensions/together/video-generation-provider.test.ts
  Test Files  3 passed (3)
       Tests  41 passed (41)

node scripts/run-vitest.mjs \
  src/agents/provider-http-errors.test.ts src/media-generation/provider-assets.test.ts
  Test Files  2 passed (2)
       Tests  24 passed (24)
  • ./node_modules/.bin/tsgo -p test/tsconfig/tsconfig.core.test.json --noEmit -> exit 0
  • ./node_modules/.bin/tsgo -p test/tsconfig/tsconfig.extensions.test.json --noEmit -> exit 0
  • ./node_modules/.bin/oxlint <the six files> -> exit 0
  • ./node_modules/.bin/oxfmt --check <the six files> -> exit 0

One flake worth naming rather than hiding

Twice during this work, extensions/vydra/shared.test.ts > bounds a dripping download body with one wall-clock deadline failed with request timed out instead of Vydra image download timed out after 250ms. Both failures were in multi-shard runs where the transform phase ran 2-3x its normal cost (73s and 50s against a usual ~25s); every warm run passed.

I tried to pin it to this change and could not:

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.

@Yigtwxx

Yigtwxx commented Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

Exact-head CI on f165d6f484d came back with three red shards. One was mine and is fixed in 8a4bbfc8528; the other two are not from this branch, measured rather than asserted.

Mine: the shared provider-http mock returns an explicit export list

checks-node-changed-extensions-config-1 and -2 failed with the same error from two different suites:

Error: [vitest] No "readProviderBinaryResponse" export is defined on the
"openclaw/plugin-sdk/provider-http" mock.
 ❯ downloadDashscopeGeneratedVideos src/video-generation/dashscope-compatible.ts:656:15
 ❯ extensions/alibaba/video-generation-provider.test.ts:254:20
 ❯ extensions/qwen/video-generation-provider.test.ts

src/plugin-sdk/test-helpers/provider-http-mocks.ts:284 mocks the module with a curated object rather than spreading the original, so anything the module gains has to be listed there. Routing the DashScope downloader through the shared reader made it reach for an export the mock did not carry. The helper already forwards assertProviderBinaryResponseContent from the real module for exactly this reason, so the repair is the same three lines one entry down:

  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 src/agents/provider-http-errors.js in DashScope. Both make the two suites pass, but the five extension owners in this PR reach the reader through the plugin-SDK barrel too, so the helper is where the class of problem ends rather than this one instance of it.

Control arm, same file, same machine, only the helper differing:

tree extensions/alibaba/video-generation-provider.test.ts
without the fix 4 failed — 2 × readProviderBinaryResponse, 2 × EBUSY
with the fix 2 failed — the 2 × EBUSY only

The residual EBUSY: resource busy or locked, unlink '...openclaw-agent.sqlite-shm' pair is the Windows vitest teardown artifact tracked in #119796; it fires from fs.rmSync in the suite's own cleanup, appears identically on the unfixed tree, and does not exist on the Linux runners.

Everything else that builds on that helper is clean at 8a4bbfc8528:

node scripts/run-vitest.mjs \
  extensions/qwen/... extensions/deepinfra/video-... extensions/pixverse/... \
  extensions/runway/... extensions/openai/video-... extensions/together/... extensions/xai/video-...
  -> all pass except the same EBUSY teardown row in extensions/openai (line 174, fs.rmSync)

node scripts/run-vitest.mjs <the seven owner suites>
  Test Files  7 passed (7)
       Tests  149 passed (149)
  • ./node_modules/.bin/tsgo -p test/tsconfig/tsconfig.core.test.json --noEmit -> exit 0
  • ./node_modules/.bin/oxlint src/plugin-sdk/test-helpers/provider-http-mocks.ts -> exit 0
  • ./node_modules/.bin/oxfmt --check src/plugin-sdk/test-helpers/provider-http-mocks.ts -> exit 0

Not mine: checks-node-compact-small-1

src/cli/mcp-cli.test.ts > bounds concurrent MCP doctor server checks, AssertionError: expected 0 to be greater than or equal to 4 — a concurrency-bound timing assertion. git diff --name-only origin/main...HEAD returns nothing under src/cli or any MCP path, and src/cli/mcp-cli.test.ts does not reference provider-http at all, so the file sets do not intersect this branch in either direction. openclaw/ci-gate is the aggregator reporting the three above.

New head 8a4bbfc8528.

@Yigtwxx

Yigtwxx commented Aug 21, 2026

Copy link
Copy Markdown
Contributor Author

Follow-up on the CI note above, since that run finished after I posted it.

Exact-head CI on 8a4bbfc8528 has settled at 206 passed, 1 failed, 41 skipped, and
openclaw/ci-gate is green. The single red is Validate provider scaffold, and it never got
as far as running the scaffold check:

Validate provider scaffold
Internal Error: Error when performing the request to https://registry.npmjs.org/pnpm/-/pnpm-11.15.1.tgz;
  for troubleshooting help, see https://github.com/nodejs/corepack#troubleshooting
##[error]pnpm install failed

Corepack could not fetch the pinned pnpm tarball, so the job failed during dependency install.
It is not a required job, which is why the gate is unaffected. I cannot re-run it from a fork, and
the branch has no drift to justify a refresh: git log <merge-base>..origin/main -- <the 21 files this PR touches> is empty, so main has not moved across any of them since the last measurement.
Rather than push a no-op commit purely to clear a red X and reset the review that already came back
clean, I am leaving the head where it is. Happy to retrigger if a maintainer would prefer a fully
green run.

@Yigtwxx

Yigtwxx commented Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

Refreshed onto main (b8d6e799a31) and re-measured. New head: 5dbf7ac3d5d.

Unlike the other branches I refreshed today, main has not touched any of the 21 files this PR
changes since the last measurement, so the merge was clean and the evidence below is a re-run
rather than a repair. I re-ran it anyway rather than carrying the old numbers over.

Re-measured, Windows 11, Node 24.18.1

node scripts/run-vitest.mjs <the 10 test files this PR changes>
arm result
main sources + this branch's tests 3 failed / 31 passed (34) in the first shard, run aborted there
this branch 5dbf7ac3d5d 3 shards passed — 1 + 2 + 7 files, 34 + 34 + 122 = 190 passed

Both arms on the same tree; the control arm reverts the nine provider sources and keeps this
branch's tests. It stops at the first red shard, so its count is that shard alone. The three
failures are the cases this PR exists for:

FAIL |unit| src/video-generation/dashscope-compatible.test.ts
  > rejects 'Qwen' 'empty video' responses instead of returning a video
  > rejects 'Alibaba Wan' 'empty video' responses instead of returning a video
  > rejects a malformed response while a debug-capture clone still holds the body tee

The third is the one that matters most: with the debug proxy's capture clone still holding the
body tee, the rejection path never settles on main, so the provider's own
malformed video response error never reaches the user and the call hangs until a surrounding
timeout fires instead.

On the red Validate provider scaffold check

That failure is infrastructure, not this branch. The job log for run 32271559227 shows corepack
failing to fetch the package manager itself:

Internal Error: Error when performing the request to
https://registry.npmjs.org/pnpm/-/pnpm-11.15.1.tgz

It fails twice in a row at that step, before any repository code is compiled or executed, and the
job never reaches the scaffold validation it is named for. This push should give it a fresh run.

oxlint and oxfmt --check are clean across all 21 touched files.

@Yigtwxx

Yigtwxx commented Aug 28, 2026

Copy link
Copy Markdown
Contributor Author

Refreshed onto main (babb2fc7c13) — the branch had gone dirty and one test broke on current main. New head 89c31cee5.

Conflict. extensions/comfy/image-generation-provider.test.ts conflicted with #130098 (comfy custom headers and per-request seed). Both sides only added to the same regions, so both are kept: seedFromBody and the header/seed tests from main, the download parameter on mockLocalImageResponses and the malformed-download cases from this branch.

One real break from main drift. extensions/xai/video-generation-transport.test.ts > cancels the unread response body when the content type is rejected failed after the merge with expected 1 call, got 2. Traced, not guessed:

cancel #1  readProviderBinaryResponse        src/agents/provider-http-errors.ts:512
cancel #2  cancelUnreadResponseBody -> releaseDispatcher -> release
           src/infra/net/fetch-guard.ts:569  (added by #130804)

#130804 made the guarded fetch's release path cancel an unread body, so a rejected download is now cancelled twice — harmless, since ReadableStream.cancel() is idempotent, but it invalidates an exact call count. The assertion was over-specified: this test's invariant is that the body is cancelled on rejection, not how many owners cancel it, so it now asserts toHaveBeenCalled(). No production code changed.

Verification on the new head

Check Result
vitest run over all 10 test files touched by this PR 197 passed
Mutation control: revert the 9 production files to origin/main, keep the tests 16 failed
scripts/check-assertion-safety-ratchet.mts OK (4200 files)
scripts/check-max-lines-ratchet.mts OK (887 suppressions)
oxfmt --check, oxlint on both touched test files clean

The mutation control is the part that matters for triage: main has not fixed this independently — without the download validation, 16 tests across xai, fal and vydra still fail today.

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]>
@obviyus

obviyus commented Sep 5, 2026

Copy link
Copy Markdown
Collaborator

Ready for guarded landing at 24c7fcbc12c3f792290f654e0ea9e32666d1e7f9.

  • Exact-head CI is green: run 33966539392, attempt 2.
  • Fresh independent review: zero findings, security cleared, sufficient product proof, no remaining rank-up moves.
  • The shipped CLI falsely saved JSON/HTML as successful generated-video output on main; this head returns a provider-labelled error and saves nothing.
  • The same CLI saves a complete playable H.264 MP4 after a 31-second download pause; a full decoder run exits 0.
  • Focused/sibling tests: 367 passed. The regression control produces 46 failures against unchanged baseline production.
  • CI attempt 1 had a Gateway clock-jump integration timeout. That text-only, minimal-tool scenario does not invoke these downloaders; it passed on main and on the single failed-jobs rerun without a code or timeout change.

Validation used isolated Linux source checkouts at the exact baseline and candidate commits. No paid provider or channel-delivery claim is made.

Exact validation commands
node 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.

@obviyus

obviyus commented Sep 5, 2026

Copy link
Copy Markdown
Collaborator

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.

  • Bug: successful HTTP responses could become invalid generated-video files, and captured rejected bodies could delay errors.
  • Fix: the download owners use the canonical binary reader while retaining their existing deadlines, overflow behavior, and metadata.
Before After
CLI reported success and saved JSON/HTML as video output Clear provider-labelled failure; no output file
Held malformed body reached a request timeout Prompt malformed-response error
Valid slow download completed Still completes; saved H.264 video fully decodes

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: comfy extensions: fal extensions: google extensions: minimax extensions: openrouter extensions: together extensions: vydra extensions: xai P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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