Skip to content

fix(media): convert multi-frame HEIC and HEIF photos for image providers - #128501

Merged
steipete merged 1 commit into
mainfrom
codex/qa-heic-sequence-image-input-20260823
Aug 24, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/qa-heic-sequence-image-input-20260823

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where users uploading valid multi-frame HEIC or HEIF photos would see Gateway image requests rejected, or would have unsupported image bytes silently passed to image-description providers, when the image detector identified the files as HEIC/HEIF image sequences.

Why This Change Was Made

The pinned image detector correctly distinguishes sequence variants from ordinary HEIC/HEIF images, but the existing Gateway input owner and media-understanding image detector recognized only the still-image MIME names. Normalize exactly the two existing sequence aliases at the canonical image-conversion boundary, and recognize them before image-provider execution, while preserving byte-signature validation, restrictive configured MIME allowlists, conversion limits, public MIME detection, and existing HEIC/HEIF defaults. The production change is +3 lines; it adds no configuration, dependency, public API, or accepted image family.

User Impact

Valid HEIC and HEIF image sequences are converted into ordinary JPEG images before Gateway and image-understanding provider delivery, including inputs with opaque filenames. Spoofed non-image content and image types excluded by operator configuration remain rejected.

Evidence

  • Captured seven failing pre-fix regressions across inline and guarded-URL Gateway image input, image-description provider execution, and explicit image-model execution; all pass after the owner-boundary repair.
  • Generated genuine 64x64 two-frame HEIC images and exercised the real pinned MIME detector, both production image-input paths, the real Rastermill/ImageMagick JPEG decoder, and Anthropic's actual accepted-image MIME boundary. Ordinary heix, HEIC-sequence hevc, and HEIF-sequence msf1 inputs all produced provider-accepted JPEG bytes beginning with ffd8ff.
  • The end-to-end proof used one explicitly disclosed Node test-module seam only to mark this host's already-broken system sips backend unavailable; every other executable was selected by the original trusted production resolver. Existing follow-up: on this macOS host, sips produces unreadable JPEG output even for ordinary previously supported HEIC, and the image dependency currently stops before its working ImageMagick backend.
  • Focused owner and sibling proof: node scripts/run-vitest.mjs src/media/input-files.fetch-guard.test.ts src/media-understanding/runtime.test.ts src/media-understanding/apply.test.ts packages/media-core/src/mime.test.ts --configLoader runner — 311 tests passing.
  • Independent owner/provider review: 320 tests passing, including restrictive allowlist and spoofed-content rejection, plus an independently repeated genuine two-frame Gateway/provider JPEG proof.
  • Production typecheck: pnpm tsgo:core; exact touched test-owner typechecks: node scripts/run-tsgo.mjs -b test/tsconfig/tsconfig.core.test.other.json --builders 1 and node scripts/run-tsgo.mjs -b test/tsconfig/tsconfig.core.test.plugins-platform.json --builders 1; targeted formatting and lint checks all pass.
  • The unrelated complete UI test-type stripe cannot run against this host's shared dependency install because it lacks @panzoom/panzoom and @types/pako; both actual changed-owner test-type programs pass independently.

@clawsweeper

clawsweeper Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Aug 24, 2026
@steipete
steipete marked this pull request as ready for review August 24, 2026 04:54
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. 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. labels Aug 24, 2026
@clawsweeper

clawsweeper Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed August 24, 2026, 1:02 AM ET / 05:02 UTC.

ClawSweeper review

What this changes

The PR recognizes HEIC and HEIF sequence MIME types and converts them to JPEG before Gateway and media-understanding image-provider requests.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open: the branch repairs Gateway and media-understanding conversion, but leaves the parallel openclaw model run --file path forwarding HEIC/HEIF sequence bytes without JPEG conversion.

Priority: P1
Reviewed head: ffdad4af79675fd355578422adf753861da73d1e

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The stated real conversion evidence is useful, but a concrete parallel direct-provider path remains unfixed.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: The provided repository state identifies this as a maintainer-authored PR, so the external-contributor proof gate does not apply; the body nevertheless reports genuine two-frame after-fix conversion evidence.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The provided repository state identifies this as a maintainer-authored PR, so the external-contributor proof gate does not apply; the body nevertheless reports genuine two-frame after-fix conversion evidence.
Evidence reviewed 6 items Gateway conversion owner: The changed owner collapses only the two detected sequence aliases to existing HEIC/HEIF MIME names before the existing allowlist and JPEG conversion, preserving the configured still-image allowlist contract.
Two repaired media-understanding callers: Configured media-understanding and explicit image-description calls both pass detected media into the changed normalizer before provider execution.
Unfixed direct model-run path: Current main detects a MIME for every model-run file, but converts only image/heic and image/heif; image/heic-sequence and image/heif-sequence therefore reach the provider unchanged.
Findings 1 actionable finding [P1] Normalize sequence MIME types in the model-run path
Security None None.

Live Verification

Command: pnpm openclaw model run --help

Result: FAIL (partial) — step 2 expect_output Usage:: expected terminal output was not visible within 30 seconds: "Usage:"

runner@runnervm76f27:/tmp/clawsweeper-live-proof-128501-cXWWqB/target$ pnpm openclaw model run --help
$ node scripts/run-node.mjs model run --help
pnpm openclaw model run --help
[openclaw] Building TypeScript (dist is stale: missing_build_stamp - build stamp missing).
[openclaw] Building bundled plugin assets.
[canvas] build: node scripts/bundle-a2ui.mjs
[log] ‹DIR›/a2ui.bundle.js  chunk │ size: 399.96 kB
[log] ‹DIR›/a2ui-v0.9.bundle.js  chunk │ size: 615.66 kB
[log]
[success] rolldown v1.2.0 Finished in 103.39 ms
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
[tsdown-build] invocation 1/2 finished in 0.7s
node_modules/playwright-core/lib/coreBundle.js (65821:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65821:29 ]
       │
 65821 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/playwright-core/lib/coreBundle.js (65828:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65828:29 ]
       │
 65828 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2343:30) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2343:31 ]
      │
 2343 │           ASM_CONSTS[start] = eval(func);
      │                               ──┬─
      │                                 ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2366:32) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2366:33 ]
      │
 2366 │           moduleExports[name] = eval(func);
      │                                 ──┬─
      │                                   ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

[tsdown-build] invocation 2/2 finished in 14.2s
[plugin-control-plane-loads] verified 35 built modules with native require and checked doctor closures
runtime-postbuild: 11 phases completed in 4235ms (slowest: built plugin control-plane loads 3513ms)


Assertions:

  • FAIL expect_output: Usage:

How this fits together

OpenClaw accepts image bytes through Gateway input and direct media-description APIs, detects their MIME type, applies an operator allowlist, then converts HEIC-family images before sending them to an image provider. The CLI model-run command is another direct provider-input path with its own HEIC conversion check.

flowchart LR
  Upload[Gateway or file image input] --> Detect[MIME detection]
  Detect --> Validate[Allowlist and byte validation]
  Validate --> Convert[HEIC-family JPEG conversion]
  Convert --> Provider[Image provider request]
  ModelRun[CLI model run file input] --> Detect
  ModelRun --> Provider
Loading

Before merge

  • Normalize sequence MIME types in the model-run path (P1) - The new sequence normalization reaches Gateway and media-understanding, but model run --file still uses the same detector and only converts image/heic and image/heif. A detected image/heic-sequence or image/heif-sequence therefore reaches the direct provider call unchanged, preserving the reported failure on that supported CLI path. Extend that set or share the normalization, with sequence cases beside the existing CLI HEIC regression.
  • Resolve merge risk (P1) - The bug-fix diff has a net production increase of three lines; that growth is justified only if the same sequence-alias invariant is completed for the remaining direct model-run provider path.
  • Complete next step (P2) - Fix the concrete P1 sibling-path omission on this maintainer-labeled PR before merge; no separate repair job should be opened.

Findings

  • [P1] Normalize sequence MIME types in the model-run path — src/media-understanding/image-input-normalize.ts:7
Agent review details

Security

None.

PR surface

Source +3, Tests +111. Total +114 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 2 5 2 +3
Tests 3 139 28 +111
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 144 30 +114

Review metrics

Metric Value Why it matters
Production versus regression-test delta production +5/-2 (net +3); tests +139/-28 (net +111) The small production change is paired with broad regression coverage, but the unmodified CLI provider-input owner remains outside that coverage.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Apply the same two sequence aliases to the CLI model-run conversion decision, add table-driven CLI coverage for them, and retain byte detection plus the existing HEIC/HEIF allowlist behavior.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Apply the same two sequence aliases to the CLI model-run conversion decision, add table-driven CLI coverage for them, and retain byte detection plus the existing HEIC/HEIF allowlist behavior.

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

Yes, from source: a detector result of image/heic-sequence or image/heif-sequence passes the model-run image check but misses its two-value conversion set, leaving raw bytes for the provider.

Is this the best way to solve the issue?

No: the approach is correct for the changed owners but is incomplete because the equivalent direct model-run conversion owner retains the old two-value policy.

Full review comments:

  • [P1] Normalize sequence MIME types in the model-run path — src/media-understanding/image-input-normalize.ts:7
    The new sequence normalization reaches Gateway and media-understanding, but model run --file still uses the same detector and only converts image/heic and image/heif. A detected image/heic-sequence or image/heif-sequence therefore reaches the direct provider call unchanged, preserving the reported failure on that supported CLI path. Extend that set or share the normalization, with sequence cases beside the existing CLI HEIC regression.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P1: A valid image sequence can still be sent unconverted through the direct model-run image-provider workflow.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: The provided repository state identifies this as a maintainer-authored PR, so the external-contributor proof gate does not apply; the body nevertheless reports genuine two-frame after-fix conversion evidence.

Label justifications:

  • P1: A valid image sequence can still be sent unconverted through the direct model-run image-provider workflow.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: The provided repository state identifies this as a maintainer-authored PR, so the external-contributor proof gate does not apply; the body nevertheless reports genuine two-frame after-fix conversion evidence.

Evidence

What I checked:

  • Gateway conversion owner: The changed owner collapses only the two detected sequence aliases to existing HEIC/HEIF MIME names before the existing allowlist and JPEG conversion, preserving the configured still-image allowlist contract. (src/media/input-files.ts:306, ffdad4af7967)
  • Two repaired media-understanding callers: Configured media-understanding and explicit image-description calls both pass detected media into the changed normalizer before provider execution. (src/media-understanding/runner.entries.ts:806, ffdad4af7967)
  • Unfixed direct model-run path: Current main detects a MIME for every model-run file, but converts only image/heic and image/heif; image/heic-sequence and image/heif-sequence therefore reach the provider unchanged. (src/cli/capability-cli/model.ts:131, d2e62c6b8206)
  • Existing sibling regression coverage: The existing CLI regression test protects ordinary HEIC conversion but has no sequence-alias cases, so it would not catch the remaining direct-provider failure. (src/cli/capability-cli.test.ts:1264, ffdad4af7967)
  • Detector integration boundary: Media Core calls the pinned file-type dependency for byte detection, while the changed runtime tests use real ftyp hevc and msf1 headers through that boundary; the PR therefore depends on detector output rather than filename inference. (packages/media-core/src/mime.ts:192, ffdad4af7967)
  • History routing: Available blame attributes the pre-PR model-run HEIC conversion policy to the shallow-history boundary at 7b49f57; the PR itself is commit ffdad4a. (src/cli/capability-cli/model.ts:56, 7b49f57c054a)

Likely related people:

  • steipete: Authored the current PR and its exact Gateway/media-understanding normalization changes. (role: recent media conversion contributor; confidence: high; commits: ffdad4af7967; files: src/media/input-files.ts, src/media-understanding/image-input-normalize.ts)
  • Yiğit ERDOĞAN: Available shallow-history blame traces the existing model-run HEIC conversion condition to the parent-history boundary; deeper provenance was unavailable locally. (role: pre-PR conversion-policy contributor; confidence: low; commits: 7b49f57c054a; files: src/cli/capability-cli/model.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Extend openclaw model run --file conversion to both sequence MIME aliases and add focused regression cases.
  • Rerun the focused media and CLI model-run regression suites on the updated head.

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.

@steipete
steipete merged commit f59c743 into main Aug 24, 2026
301 checks passed
@steipete
steipete deleted the codex/qa-heic-sequence-image-input-20260823 branch August 24, 2026 05:26
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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

Labels

maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant