Repository navigation
fix(cli): preserve buffered media output on write failure - #117934
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 2, 2026, 6:06 AM ET / 10:06 UTC. ClawSweeper reviewWhat this changesThe PR stages buffered image and video CLI output in a sibling temporary file and atomically replaces Merge readinessKeep open for explicit maintainer review: the patch is a focused, source-backed data-integrity repair with strong real CLI proof, but the protected Priority: P2 Review scores
Verification
How this fits togetherOpenClaw's local infer CLI receives generated image/video assets from provider runtimes and publishes them to an operator-selected output path. This change sits at that publication boundary, preserving an existing destination when a producer or filesystem write fails. flowchart LR
A[Media provider result] --> B[Infer image or video command]
B --> C[CLI output publication]
C --> D[Sibling temporary file]
D -->|complete write| E[Atomic replacement]
D -->|write failure| F[Existing destination preserved]
Decision needed
Why: The code and real behavior proof support the repair, but repository policy requires explicit maintainer handling for protected-label items and the remaining hosted-gate state cannot be resolved from source inspection alone. Before merge
Agent review detailsSecurityNone. PR surfaceSource +17, Tests +70, Docs +1. Total +88 across 4 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one canonical atomic publication helper at the CLI output boundary, retain the focused failure coverage for buffered image/video and streamed video, and merge after the exact-head hosted gates are green and a maintainer approves the protected repair. Do we have a high-confidence way to reproduce the issue? Yes. The linked report and PR body provide a source-blind built-CLI fault-injection run on the relevant current-main lineage, and current main still directly writes buffered output to the final path. Is this the best way to solve the issue? Yes. Centralizing same-directory atomic publication at the shared CLI output boundary covers both buffered media paths without provider-specific policy or a new configuration surface. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 0bc32f0f5cf5. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (2 earlier review cycles)
|
579a968 to
826052e
Compare
|
Land-ready proof for exact head Root cause: buffered image/video generation called Provenance (clear): the direct buffered output writer originated in #62129, authored and merged by @Takhoffman on April 7, 2026. The capability-command split in #108419, authored and merged by @steipete, carried the same behavior into Canonical repair: buffered image/video output now uses one shared atomic publication helper backed by Proof:
Scope: 4 files; production |
|
Merged via squash.
|
Closes #117926
What Problem This Solves
Fixes an issue where users replacing an existing buffered image or video
--outputcould lose the original file when the filesystem write failed after truncation. The command exited nonzero, but partial generated bytes had already replaced the destination.Why This Change Was Made
Buffered image and video publication now share the same sibling-temp atomic owner already used by streamed video output. A producer writes beside the destination, and OpenClaw renames that complete file into place only after success. The shared helper also centralizes existing-mode preservation and removes the duplicated streamed-video temp/mode path.
This stays at the CLI output publication boundary. Provider-specific guards would not protect every buffered media provider, and changing provider runtimes is unnecessary because they correctly return complete in-memory assets.
User Impact
Failed buffered image and video writes no longer destroy an existing output file. Successful generation keeps the same command, JSON result, output naming, complete bytes, and destination mode.
Evidence
a0d4aa34661f55804b5cc68f9b04e69081069574on Blacksmith Testboxtbx_01kz0vqh64cm8zjr9sazmgfxtf/ run30741184034: deterministic fault injection made both real built-CLI commands exit 1 after replacing the existing destination with 17 generated bytes.826052eb9421511db690c27daf4c86d80271e0b0on Blacksmith Testboxtbx_01kz0y0kmsr5wfrmvfy29ehhzn/ run30742503532: 136/136 focused capability-CLI assertions passed.check:changedgate passed, including formatting, production/test typechecks, lint, boundaries, dead-code scans, database/state guards, and import-cycle checks.0640; injected partial-write failures exited 1 while preserving the original image/video bytes and mode; no sibling temp remained.Redacted exact-head built-CLI output
{ "head": "826052eb9421511db690c27daf4c86d80271e0b0", "summary": { "pass": 4, "fail": 0, "blocked": 0 }, "imageValid": { "exit": 0, "size": 2048, "mode": "0640", "tempFiles": 0 }, "imageFault": { "exit": 1, "preserved": "existing-image-fault", "mode": "0640", "tempFiles": 0 }, "videoValid": { "exit": 0, "size": 2048, "mode": "0640", "tempFiles": 0 }, "videoFault": { "exit": 1, "preserved": "existing-video-fault", "mode": "0640", "tempFiles": 0 } }gpt-image-2andsora-2identifiers are publicly documented at https://developers.openai.com/api/docs/models/gpt-image-2 and https://developers.openai.com/api/docs/models/sora-2.30742473876is green on attempt 2. Attempt 1 had one unrelated TUI PTY timeout (model did not repeat the malformed edit call); the unchangedbuild-artifactsjob and aggregateopenclaw/ci-gatepassed on rerun.Production delta: +42/-25 (net +17, primarily the shared atomic owner). Tests: +70/-0. Docs: +1/-0. No config, protocol, storage, migration, dependency, provider-runtime, or Gateway change.
AI-assisted: yes.