Skip to content

fix(media): decode local file URLs safely - #122192

Merged
steipete merged 2 commits into
mainfrom
codex/windows-media-pdf-file-url-publish-current
Aug 11, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/windows-media-pdf-file-url-publish-current

Conversation

@steipete

@steipete steipete commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Decode host-local file:// references through the canonical safeFileURLToPath contract instead of stripping the scheme manually.
  • Route PDF local-reference access through the same shared media owner used by image and generation tools, removing duplicated sandbox/root handling.
  • Keep the root helper module-private, remove its obsolete argument and the superseded sandbox-helper barrel export, and test behavior only through the public reference-access owner.
  • Add native Windows Unicode-and-space coverage through registered image/PDF tools and image generation, plus shared security/pass-through and Windows CI routing coverage.

Root cause and owner

The shared host media resolver and the PDF tool manually removed the file:// prefix. On Windows that left /C:/... paths and percent-encoded Unicode/spaces, so otherwise valid local files failed containment/loading. resolveMediaToolReferenceAccess is the canonical owner: it now classifies the reference and delegates local file URLs to safeFileURLToPath; PDF reuses that owner while preserving sandbox bridge validation, local roots, remote SSRF policy, and non-file references.

The attributable dependency gate also showed that the internal root helper had been exported unnecessarily and an obsolete sandbox-helper re-export remained. The final head makes the root helper private, removes only those dead surfaces, and keeps direct canonical imports unchanged.

Verification

  • Authentic Windows RED: registered media flow failed 0/1 with LocalMediaAccessError on /C:/...caf%C3%A9%20image.png.
  • Windows GREEN: affected media tests 59/59, registered Unicode/space image + PDF + image-generation flow, PDF suite 38/38, barrel runtime contract 4/4, routing/package 63/63.
  • Linux: media/PDF 58 passed with the Windows-native test skipped; barrel contract 4/4; routing/package 63/63.
  • Dependency contract: current pinned @openclaw/[email protected] source/types and direct Linux/Win32 conversion/rejection proof passed. An isolated 0.5.2 compatibility proof passed the same Unicode/space and unsafe-host/encoded-separator contract.
  • API surface clean; deadcode:exports and deadcode:dependencies clean; direct oxfmt, oxlint, and git diff --check clean.
  • Production LOC: +21/-34 (net -13). Tests: +259/-25. Tooling/metadata: +2/-2.
  • Fresh independent exact-nine review and structured Sol/high max-P1 review both clean; TruffleHog clean; structured correctness 0.94.

Current-main composition

Fresh origin/main was 5179e1235293bbd80c623cf3b6359414b1cb1e74. Its only scoped drift is a hunk-disjoint package.json change to duplicate-check commands around line 1610; this PR changes the Windows CI test list around line 1968. git merge-tree --write-tree origin/main HEAD completed cleanly with tree 51f0bc60820e539adb3db3219c9eb304028c586f, so the exact reviewed head was preserved rather than rebased for unrelated churn.

@clawsweeper

clawsweeper Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper review

@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts agents Agent runtime and tooling labels Aug 11, 2026
@clawsweeper

clawsweeper Bot commented Aug 11, 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:

@openclaw-barnacle openclaw-barnacle Bot added size: M maintainer Maintainer-authored PR labels Aug 11, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 11, 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:

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 11, 2026
@clawsweeper

clawsweeper Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 11, 2026, 3:02 PM ET / 19:02 UTC.

ClawSweeper review

What this changes

Routes host-local file:// media and PDF references through the shared safe converter, removes duplicate PDF path handling, and adds native Windows regression coverage.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open for normal maintainer review: current main still manually strips file URLs in the shared resolver and PDF tool, while this PR centralizes conversion through the existing safe path contract. It is a maintainer-authored, maintainer-labeled item, so it is not eligible for automated cleanup.

Priority: P2
Reviewed head: 37b7182346804aa7201b44bd50b6d82aad7cf51b
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The repair is a focused owner-boundary consolidation with relevant Windows and security-path coverage; no actionable patch defect was found.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: This maintainer-authored PR is outside the external-contributor proof gate; its body nevertheless records a native Windows failing-and-passing registered-tool run and Windows CI coverage.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is outside the external-contributor proof gate; its body nevertheless records a native Windows failing-and-passing registered-tool run and Windows CI coverage.
Evidence reviewed 6 items Current-main defect: The shared resolver strips only the literal file:// prefix, leaving Windows drive prefixes and percent escapes unconverted before local-root enforcement.
Duplicated PDF path handling: The PDF tool independently performs the same manual file:// stripping before loading and root checks, so routing it through the shared resolver is the correct owner-boundary repair.
Established safe conversion contract: The local-file access facade re-exports safeFileURLToPath from the pinned fs-safe dependency, and the media loader already uses it for file URLs.
Findings None None.
Security None None.

How this fits together

Media tools turn local, sandboxed, and remote references into bytes for image, PDF, and generation workflows. The shared resolver determines the reference kind, enforces sandbox or local-root policy, and passes the resulting path to the media loader.

flowchart LR
  A[Tool input] --> B[Media reference resolver]
  B --> C{Reference kind}
  C -->|Local file URL| D[Safe path conversion]
  C -->|Sandboxed reference| E[Sandbox bridge validation]
  C -->|Remote reference| F[Remote access policy]
  D --> G[Local root checks]
  E --> G
  F --> H[Media loader]
  G --> H
  H --> I[Image or PDF tool]
Loading

Decision needed

Question Recommendation
Should this maintainer-authored Windows media-path fix be merged once the exact head’s remaining check completes? Merge after exact-head CI: Accept the shared-resolver repair once the remaining required check is green.

Why: The author is listed as a repository member and the PR carries the protected maintainer label, so automated cleanup must pause for a maintainer decision despite the absence of a code finding.

Before merge

  • Resolve merge risk (P1) - Independent inspection of the pinned fs-safe source was unavailable because this checkout has no installed dependencies and the promisor remote DNS lookup failed; the PR's reported Windows contract proof and exact-head CI remain the available dependency evidence.
  • Complete next step (P2) - No mechanical repair remains: this protected maintainer PR needs normal maintainer merge review after its exact-head checks settle.
Agent review details

Security

None.

PR surface

Source -13, Tests +234, Config 0, Other 0. Total +221 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 3 21 34 -13
Tests 4 259 25 +234
Docs 0 0 0 0
Config 1 1 1 0
Generated 0 0 0 0
Other 1 1 1 0
Total 9 282 61 +221

Review metrics

Metric Value Why it matters
Production versus test LOC production +21/-34 (net -13); tests +259/-25 The repair removes duplicate production policy while adding boundary-level Windows regressions for the affected tools.

Stored data model

Persistent data-model change detected: migration/backfill/repair: package.json. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Merge the canonical shared-resolver repair after the remaining exact-head checks complete, retaining the registered Windows tool-flow regression coverage and existing sandbox policy behavior.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Merge the canonical shared-resolver repair after the remaining exact-head checks complete, retaining the registered Windows tool-flow regression coverage and existing sandbox policy behavior.

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

Yes, from current source: on Windows, pass a Unicode-and-space pathToFileURL through a registered image or PDF tool; current main strips the scheme but leaves /C:/ and percent escapes before local loading.

Is this the best way to solve the issue?

Yes. Updating the existing shared reference-access owner fixes image and generation callers together, while moving PDF off its duplicate conversion path preserves the sandbox and root-policy boundaries.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This fixes a bounded Windows failure in local media access for registered image, PDF, and generation tools.
  • 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. Not applicable: This maintainer-authored PR is outside the external-contributor proof gate; its body nevertheless records a native Windows failing-and-passing registered-tool run and Windows CI coverage.

Evidence

What I checked:

  • Current-main defect: The shared resolver strips only the literal file:// prefix, leaving Windows drive prefixes and percent escapes unconverted before local-root enforcement. (src/agents/tools/media-tool-shared.ts:627, 7fe75acb5f46)
  • Duplicated PDF path handling: The PDF tool independently performs the same manual file:// stripping before loading and root checks, so routing it through the shared resolver is the correct owner-boundary repair. (src/agents/tools/pdf-tool.ts:533, 7fe75acb5f46)
  • Established safe conversion contract: The local-file access facade re-exports safeFileURLToPath from the pinned fs-safe dependency, and the media loader already uses it for file URLs. (src/infra/local-file-access.ts:10, 7fe75acb5f46)
  • Sibling coverage and CI routing: Existing Windows coverage proves loader-level Unicode/space and unsafe-file-URL behavior; the PR adds the otherwise missing registered-tool boundary and routes affected source/tests into Windows CI. (src/media/web-media.file-url.windows.test.ts:24, 7fe75acb5f46)
  • History and release status: The faulty shared resolver and PDF path were introduced together by commit 1dcac5b, which is on current main; no local release tag contains that commit. (src/agents/tools/media-tool-shared.ts:627, 1dcac5b15f87)
  • Dependency signal and inspection limit: The patch depends on @openclaw/fs-safe through the local-file facade; package metadata pins 0.5.4, but this read-only checkout has no installed dependency source and its promisor remote could not resolve for independent source inspection. (package.json:2029, 7fe75acb5f46)

Likely related people:

  • steipete: Blame attributes both duplicate manual conversion paths to the same current-main commit, whose author metadata corresponds to the PR author. (role: current behavior introducer and recent area contributor; confidence: high; commits: 1dcac5b15f87; files: src/agents/tools/media-tool-shared.ts, src/agents/tools/pdf-tool.ts)

Rating scale

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

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

Workflow

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

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-11T18:53:37.242Z sha 37b7182 :: needs maintainer review before merge. :: none

@steipete
steipete merged commit 8f4a90a into main Aug 11, 2026
206 of 208 checks passed
@steipete
steipete deleted the codex/windows-media-pdf-file-url-publish-current branch August 11, 2026 20:19
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit to tangtaizong666/openclaw that referenced this pull request Aug 11, 2026
…-prep

* commit 'edb7a1692e58d78ff7e196db39ea8eff297b2e19': (1351 commits)
  fix(telegram): expose live location updates to hooks (openclaw#122185)
  fix(ui): remove the pre-creation session row (openclaw#122259)
  fix(openai): surface failed realtime response outcomes (openclaw#121177)
  fix(logging): publish diagnostics ZIP through staged atomic overwrite (openclaw#122130)
  test(cli): trim duplicate MCP probe process cases (openclaw#122260)
  feat(agents): replay persisted native video (openclaw#122257)
  fix(test): serialize default e2e runner (openclaw#122203)
  fix(ui): always show full assistant responses (openclaw#122207)
  feat(mcp): per-requester OAuth for MCP servers (openclaw#122166)
  fix(ui): preserve focus on composer accessory clicks (openclaw#122243)
  fix(backup): exclude state temp files (openclaw#122250)
  fix(browser): let attached workers exit after CDP use (openclaw#122103)
  test(cli): trim duplicate Claw authoring process cases (openclaw#122248)
  refactor(outbound): inline delivery diagnostics (openclaw#122219)
  refactor: eliminate final wrapper-shadowing hazards (openclaw#122157)
  fix(ui): keep new-session identity anchored (openclaw#122242)
  test(cli): trim duplicate gateway process cases (openclaw#122240)
  fix(media): decode local file URLs safely (openclaw#122192)
  refactor(agents): centralize typed activity event emission (openclaw#122188)
  fix(ui): effort slider matches selected level after model switches (openclaw#122125)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 12, 2026
* fix(media): decode local file URLs safely

* refactor(media): remove obsolete helper exports
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant