Repository navigation
fix(media): resolve relative media/PDF paths against the agent workspace - #292
Merged
Merged
Conversation
There was a problem hiding this comment.
cubic analysis
All reported issues were addressed across 10 files
Linked issue analysis
Linked issue: ENG-21407: [Sentry][Fleet] OPENCLAW-FLEET-16P: Relative media and PDF paths rejected by directory containment guard
| Status | Acceptance criteria | Notes |
|---|---|---|
| ✅ | Resolve relative media and PDF paths against the workspace | The PDF tool and media-generation tools pass workspaceDir to the loader, which resolves relative references there. |
| ✅ | Allow valid files in workspace subdirectories | The PDF regression test processes ststephens/doc.pdf from the workspace, and the other tools pass workspaceDir for relative references. |
| ✅ | Keep paths that escape the workspace blocked | A regression test verifies a relative path outside the workspace is denied under workspaceOnly policy. |
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
There was a problem hiding this comment.
Code Review: APPROVE
Verdict: APPROVE (siap-rilis)
Summary & Technical Verification
- Workspace-Relative Path Resolution (OPENCLAW-FLEET-16P): Media tools (
pdf,image,image_generate,video_generate, andmusic_generate) now passworkspaceDirthrough toloadWebMedia/loadWebMediaRaw. Fixes Sentry errors where files written to workspace subfolders were rejected by containment checks against the gateway process cwd. - Centralized Resolution: Removes redundant inline path resolution logic from
src/agents/tools/image-tool.ts, establishingloadWebMediaInternalas the single canonical resolution point. - Containment & Security: Directory-traversal escapes outside the workspace remain denied, verified by explicit regression tests under
fsPolicy.workspaceOnly. - Scope Precision: Separates the plugin-adapter channel flattening issue into follow-up ENG-21421.
- Test Coverage: Added regression tests across
pdf-tool.test.ts,image-generate-tool.test.ts,music-generate-tool.test.ts, andvideo-generate-tool.test.ts. All 151 CI check runs completed cleanly.
orswn
approved these changes
Oct 14, 2026
insomnius
approved these changes
Oct 14, 2026
Agents writing a file into a workspace subfolder (e.g. "ststephens/doc.pdf") and then handing that relative path to a media tool were rejected with "Local media path is not under an allowed directory", even though the same file is reachable with read/ls and the workspace is an allowed root. assertLocalMediaAllowed has no workspace context: a non-absolute path falls through to path.resolve(mediaPath), resolving against the gateway process cwd instead of the agent workspace, then fails containment against workspace-anchored roots. loadWebMediaInternal already resolves a relative mediaUrl against an optional workspaceDir before that guard runs (already covered by web-media.test.ts), and the outbound send path already passes it via OutboundMediaAccess.workspaceDir. No media tool did. Thread workspaceDir into the loadWebMedia/loadWebMediaRaw call in pdf, image_generate, video_generate, and music_generate, matching how the image tool already resolved it -- then delete the image tool's inline duplicate of that same resolution, since the loader now owns it canonically. Fixes ENG-21407 (OPENCLAW-FLEET-16P). OPENCLAW-FLEET-XZ (tool: message) is a separate, multi-plugin gap in several channel adapters dropping workspaceDir before their own loadWebMedia calls; filed as ENG-21421. Co-Authored-By: Claude Opus 5 <[email protected]>
Drop PR-specific ticket references from inline/test comments (repo policy: no Linear ticket IDs in code/comments/commits), and replace a customer- derived example path with a generic one in docs and the regression test that mirrored it. Co-Authored-By: Claude Sonnet 5 <[email protected]>
convyusboy
force-pushed
the
ridho/eng-21407-relative-media-pdf-paths
branch
from
October 14, 2026 16:20
141ac0d to
123ad02
Compare
convyusboy
added a commit
that referenced
this pull request
Oct 15, 2026
Cut the fork release that ships the six commits on boon since v2026.6.34-boon.7: - #292 (ENG-21407): resolve relative media/PDF paths against the agent workspace in pdf, image_generate, video_generate, and music_generate, instead of the gateway process cwd; delete the image tool's duplicate inline resolution now that the loader owns it canonically. - #289 (ENG-21228): let image, pdf, image_generate, video_generate, and music_generate read agent-rendered files outside the default roots (e.g. /tmp crops) when the agent is permitted host reads outside its workspace, matching the outbound MEDIA: path; a blocked path now returns a denied tool result instead of a raw error that paged Sentry. - #293 (ENG-21406): raise the image tool's default vision timeout 60s -> 150s (above boon-llm-gateway's 120s fallback-chain budget), share one deadline across setup and the provider request, and return a graceful timeout status instead of letting the raw error end the turn; mirrored in the Codex dynamic-tool watchdog; sentry-monitor downgrades image timeouts to a warning. - #291: sentry-monitor no longer pages on ordinary non-zero exec exit codes; only shell lookup failures (126/127) stay exceptions, now fingerprinted per missing binary. Runtime Docker image adds unzip. - #288 (ENG-21227): memory_search no longer pauses/pages Sentry while the index is still building ("missing" identity); only a real "mismatched" embedding provider pauses it. - #294 (ENG-21405, test-only): regression coverage confirming the cron delivery-target guard already rejects a directory-less channel's unknown target end to end; root cause for the live Sentry errors was a stale anychat-boon-web plugin install, not a core gap. Bump root package.json and npm-shrinkwrap.json, all 136 plugin manifests, and the version field in every extension's npm-shrinkwrap.json via pnpm plugins:sync, hand-patched the same way as boon.7 (the npm-shrinkwrap generator still can't regenerate cleanly on this fork: pre-existing, unrelated @sentry/node nested @opentelemetry/resources / sdk-trace-base registry-resolution drift, reproduced again on this base). Verified via test/package-manager-config.test.ts (12/12) and the full release-preflight check suite (plugin versions, inventory, base config schema, bundled channel config metadata, config docs baseline, plugin SDK exports/API baseline/surface budget, root dependency ownership) -- all green except the known shrinkwrap generator drift. Add the 2026.6.34-boon.8 CHANGELOG.md section and the generated extensions/matrix/CHANGELOG.md entry. No config schema, plugin-SDK surface, or plugin source/dependency change in slack/msteams/diagnostics-prometheus; this is a gateway-only roll (bundled-plugin source changes in codex, memory-core, and sentry-monitor ship inside the gateway tarball). Targeted tests for all three touched extensions plus the codex dynamic-tool-execution suite: 1075/1075 passing. Co-authored-by: Claude Sonnet 5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Problem This Solves
Agents that write a file into a workspace subfolder (e.g.
ststephens/doc.pdf)and then reference it by that relative path from the
pdf,image_generate,video_generate, ormusic_generatetool get rejected withError: Local media path is not under an allowed directory, even though the same file isalready reachable with
read/lsand the workspace is an allowed root.Reported live via Sentry fleet telemetry at Peterson Sheet Metal, Guido, and
C&S Technical Resources (OPENCLAW-FLEET-16P).
Why This Change Was Made
assertLocalMediaAllowed(src/media/local-media-access.ts) has no workspacecontext: a non-absolute path falls through to
path.resolve(mediaPath),resolving against the gateway process cwd instead of the agent workspace,
then fails containment against workspace-anchored roots.
The loader already solves this correctly:
loadWebMediaInternalresolves arelative
mediaUrlagainst an optionalworkspaceDirbefore that guard runs(covered by
src/media/web-media.test.ts), and the outbound send path alreadypasses it via
OutboundMediaAccess.workspaceDir. No media tool passed it. Theimagetool separately carried a hand-rolled, inline copy of the sameresolution logic.
This change threads
workspaceDirinto theloadWebMedia/loadWebMediaRawcall from
pdf,image_generate,video_generate, andmusic_generate(matching how the image tool already resolved relative refs), then deletes the
image tool's inline duplicate so the loader is the single canonical place this
resolution happens. Net production LOC is +22/-16, mostly comments; the image
tool's own prod code shrinks by 10 lines.
User Impact
ststephens/doc.pdf)from any of the five media tools and have it resolve correctly.
with a dedicated regression test using a relative
../escape underfsPolicy.workspaceOnly.Scope note: OPENCLAW-FLEET-XZ
The ticket's second Sentry issue, OPENCLAW-FLEET-XZ (
tool: message), is adifferent, multi-plugin gap: the outbound
messagetool already threadsworkspaceDircorrectly through its core plumbing(
resolveAgentScopedOutboundMediaAccess→OutboundMediaAccess.workspaceDir),but several bundled channel adapters (Telegram, MS Teams, iMessage, WhatsApp —
and the gateway
sendRPC re-entry path for Telegram specifically) flattenmediaAccessdown to{ mediaLocalRoots, mediaReadFile }and drop.workspaceDirbefore their own terminalloadWebMediacall. That is aseparate, channel-plugin-owned fix spanning several files per plugin; filed as
ENG-21421 rather than bundled
into this PR.
Evidence
node scripts/run-vitest.mjs src/agents/tools/pdf-tool.test.ts src/agents/tools/image-tool.test.ts src/agents/tools/image-generate-tool.test.ts src/agents/tools/video-generate-tool.test.ts src/agents/tools/music-generate-tool.test.ts src/agents/tools/media-tool-shared.test.ts src/media/web-media.test.ts src/media/local-media-access.test.ts— 337/337 passed.node scripts/run-vitest.mjs src/agents/openclaw-tools.pdf-registration.test.ts src/agents/openclaw-tools.tts-config.test.ts src/agents/tools/video-generate-tool.status.test.ts src/agents/tools/music-generate-tool.status.test.ts src/agents/tools/image-tool.custom-provider-auth.regression.test.ts—22/22 passed (sibling wiring tests).
pnpm tsgo:core— clean, no errors.pnpm format:check/node scripts/run-oxlint.mjson all touched files —clean.
$autoreview(Claude engine; Codex unavailable in this environment —authentication failure) on the final diff: one P2 raised
("image-tool relative-path resolution removed without a regression test"),
resolved by existing, unmodified, real-loader coverage at
image-tool.test.ts("resolves relative image paths against workspaceDir"),re-verified green (97/97) after the change.
pdf-tool.test.ts(relative path resolves; relativetraversal escape still denied),
image-generate-tool.test.ts,video-generate-tool.test.ts,music-generate-tool.test.ts(each provesworkspaceDirreaches the loader for a relative reference).git diff --numstat— non-test prod LOC +22/-16 (net +6, comments); testLOC +223 across 4 files.
Known gap: no Crabbox/live-channel proof was run for this PR (narrow,
single-module fix); CI will cover broader lanes.
🤖 Generated with Claude Code
Summary by cubic
Fixes media tools rejecting relative media and PDF paths that point inside the agent workspace. Previously the
pdf,image_generate,video_generate, andmusic_generatetools resolved a non-absolute path against the gateway process cwd, which failed the workspace containment check even when the file was valid. They now threadworkspaceDirthrough to the media loader, and the image tool's inline copy of the same resolution logic is removed since the loader handles it canonically.messagetool is out of scope: channel adapters dropworkspaceDirbefore their own media load, filed separately as ENG-21421.Written for commit 123ad02. Summary will update on new commits.