Repository navigation
fix(media): keep an unquoted MEDIA path with spaces as one media item - #112464
Conversation
baf76fe to
f3725ea
Compare
|
Codex review: needs changes before merge. Reviewed August 1, 2026, 1:45 PM ET / 17:45 UTC. ClawSweeper reviewWhat this changesThe PR changes unquoted Merge readinessKeep this PR open: it strongly fixes the reported rooted-path failure and includes maintainer-provided real attachment-loading proof, but the new grouping rule still splits two unquoted relative local media paths that each contain spaces. That leaves a concrete media-delivery gap in the stated behavior, so it needs one focused parser repair and regression case before merge. Priority: P1 Review scores
Verification
How this fits togetherAssistant output is parsed for legacy flowchart LR
A[Assistant reply text] --> B[MEDIA directive parser]
B --> C[Validated media references]
C --> D[Reply normalization]
D --> E[Outbound payload plan]
E --> F[Media loader]
F --> G[Delivered attachment]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +31, Tests +61. Total +92 across 2 files. View PR surface stats
Review metricsNone. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Extend the canonical parser’s grouping rule to cover supported relative local paths as well as rooted paths, while retaining the existing independent-root, URL, traversal, and completed-file boundaries; add a two-relative-spaced-path regression test and repeat the attachment-loading proof. Do we have a high-confidence way to reproduce the issue? Yes—source inspection gives a high-confidence path: Is this the best way to solve the issue? No—the current rooted-only grouping rule is not the best complete repair because the parser already supports relative local media paths. Extending the same canonical boundary logic to relative paths, with a focused regression test, is the narrower maintainable fix. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 5118b0b915c0. LabelsLabel changes:
Label justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (7 earlier review cycles)
|
ce31d53 to
f50ecb0
Compare
Review response — 2026-07-27[P1] Preserve mixed absolute and relative media directives — resolved. The first collapse guard now also requires at least one whitespace-separated fragment without a file extension before treating the payload as a single spaced path. A real spaced path always has an extension-less fragment ( !unwrapped &&
parts.length > 1 &&
+ !parts.every((part) => HAS_FILE_EXT.test(cleanCandidate(part))) &&
/\s/.test(payloadValue) &&Real-behavior proof — the actual
Regression test added ( |
fa23db1 to
bdc22d7
Compare
Maintainer real attachment-delivery verificationPreserved original @MatthewSynthia Git author/email/first authored date and issue reporter @Ali-Al1; refreshed the original PR onto current main and removed the unrelated bundled relay change. Exact head Created two real PNG files in directories and filenames containing spaces, then exercised production Before: the one-image reply produced three invalid attachment fragments; two images produced five invalid fragments. The real loader returned After: one image loads once; both independent images load separately, each 68 bytes with exact original PNG bytes. Parser, reply payload, and outbound payload agree exactly. Quoted paths are unchanged; Windows drives, double spaces, UNC, mixed relative attachments, traversal rejection, safe surviving siblings, and blocked loopback URLs are all verified. node --import tsx --input-type=module -e 'import { mkdtemp, mkdir, writeFile, rm, realpath } from "node:fs/promises"; import { tmpdir } from "node:os"; import path from "node:path"; const temp = await mkdtemp(path.join(tmpdir(), "openclaw-112421-proof-")); const root = await realpath(temp); try { const aDir = path.join(root, "My Files", "Project Assets"); const bDir = path.join(root, "Second Album"); await mkdir(aDir, { recursive: true }); await mkdir(bDir, { recursive: true }); const first = path.join(aDir, "render final.png"); const second = path.join(bDir, "another photo.png"); const png = Buffer.from("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+rH9sAAAAASUVORK5CYII=", "base64"); await writeFile(first, png); await writeFile(second, png); const { splitMediaFromOutput } = await import("./src/media/parse.ts"); const { normalizeReplyPayloadDirectives } = await import("./src/auto-reply/reply/reply-delivery.ts"); const { createOutboundPayloadPlan } = await import("./src/infra/outbound/payloads.ts"); const { loadWebMedia } = await import("./src/media/web-media.ts"); for (const [scenario, text] of [["single-png", "Image ready\nMEDIA:" + first], ["two-png", "Images ready\nMEDIA:" + first + " " + second], ["quoted-png", "Quoted image\nMEDIA:\"" + first + "\""]]) { const parsed = splitMediaFromOutput(text); const reply = normalizeReplyPayloadDirectives({ payload: { text }, parseMode: "always" }).payload; const outbound = createOutboundPayloadPlan([{ text }]).map((entry) => entry.payload); const loaded = []; for (const media of parsed.mediaUrls ?? []) { try { const item = await loadWebMedia(media, { localRoots: [root] }); loaded.push({ path: media, kind: item.kind, bytes: item.buffer.length, exactBytes: item.buffer.equals(png) }); } catch (error) { loaded.push({ path: media, error: error.code ?? error.message }); } } console.log(JSON.stringify({ scenario, caption: parsed.text, parsed: parsed.mediaUrls ?? [], reply: reply.mediaUrls ?? [], outbound: outbound.map((entry) => entry.mediaUrls ?? []), loaded })); } const windows = "C:\\Users\\First Last\\workspace\\shot.png"; for (const [scenario, text] of [["windows-two", "MEDIA:" + windows + " D:\\Other User\\second.png"], ["windows-relative", "MEDIA:" + windows + " media/second.png"], ["unc", "MEDIA:\\\\server\\My Files\\Project Assets\\render final.png"], ["windows-traversal", "MEDIA:C:\\Users\\First Last\\..\\secret.png"], ["posix-traversal", "MEDIA:/tmp/project screenshots/../../.env"], ["traversal-plus-safe", "MEDIA:/tmp/project screenshots/../../.env /tmp/safe/second.png"], ["blocked-ssrf", "MEDIA:" + windows + " https://127.0.0.1/secret.png"]]) { const output = splitMediaFromOutput(text); console.log(JSON.stringify({ scenario, text: output.text, parsed: output.mediaUrls ?? [] })); } } finally { await rm(root, { recursive: true, force: true }); }'
OPENCLAW_VITEST_FS_MODULE_CACHE_PATH=/private/tmp/openclaw-vitest-s02-112464-media node scripts/run-vitest.mjs src/media/parse.test.ts src/auto-reply/reply/reply-delivery.test.ts src/infra/outbound/payloads.test.ts
.agents/skills/autoreview/scripts/autoreview --mode uncommitted --engine codex --thinking xhigh158 tests pass across all three owner/caller suites; targeted formatter and diff checks pass; fresh Codex Sol xhigh autoreview is clean. Both latest ClawSweeper rank-up moves are complete. Fixes #112421. |
|
Merged via squash.
|
* origin/main: (26 commits) fix(update): return failure when dirty checkout blocks update (#117452) fix(auto-reply): apply mixed chat directives in one session transaction (#117542) refactor(ui): unify channel status and setup controls (#117499) fix(doctor): preserve surviving lint selections (#117543) fix(media): keep an unquoted MEDIA path with spaces as one media item (#112464) refactor(channels): consolidate lightweight plugin discovery (#117541) fix(imessage): prevent duplicate messages after delayed sends (#110853) refactor(memory): unify authoritative dreaming state and presentation (#117538) refactor(agents): consolidate main-session recovery ownership (#117383) fix(proxy-capture): make path-based session cleanup atomic (#98852) refactor(agents): consolidate compaction and context-engine ownership (#117482) fix(gateway): preserve Responses usage details (#117533) perf(gateway): skip empty session recovery stores (#117498) fix(ci): update canonical Kova performance pin (#117508) fix(system-agent): emit the wizard cancel hint once per message (#113731) refactor: dedupe secrets runtime snapshot fixtures (#117502) test(google): cover ready callback close precedence test(openai): dedupe realtime voice fixtures (#117503) fix(google): flush lazy prompts on provider readiness fix(gateway): keep canonical hooks on pristine startup path (#117493) ...
* origin/main: (35 commits) fix(update): return failure when dirty checkout blocks update (openclaw#117452) fix(auto-reply): apply mixed chat directives in one session transaction (openclaw#117542) refactor(ui): unify channel status and setup controls (openclaw#117499) fix(doctor): preserve surviving lint selections (openclaw#117543) fix(media): keep an unquoted MEDIA path with spaces as one media item (openclaw#112464) refactor(channels): consolidate lightweight plugin discovery (openclaw#117541) fix(imessage): prevent duplicate messages after delayed sends (openclaw#110853) refactor(memory): unify authoritative dreaming state and presentation (openclaw#117538) refactor(agents): consolidate main-session recovery ownership (openclaw#117383) fix(proxy-capture): make path-based session cleanup atomic (openclaw#98852) refactor(agents): consolidate compaction and context-engine ownership (openclaw#117482) fix(gateway): preserve Responses usage details (openclaw#117533) perf(gateway): skip empty session recovery stores (openclaw#117498) fix(ci): update canonical Kova performance pin (openclaw#117508) fix(system-agent): emit the wizard cancel hint once per message (openclaw#113731) refactor: dedupe secrets runtime snapshot fixtures (openclaw#117502) test(google): cover ready callback close precedence test(openai): dedupe realtime voice fixtures (openclaw#117503) fix(google): flush lazy prompts on provider readiness fix(gateway): keep canonical hooks on pristine startup path (openclaw#117493) ...
* origin/main: (491 commits) feat(gateway): advertise chat attachment limits on hello-ok (#116188) fix(ui): preserve full graphemes in session owner initials (#117350) refactor(tui): consolidate runtime ownership (#117368) fix(update): return failure when dirty checkout blocks update (#117452) fix(auto-reply): apply mixed chat directives in one session transaction (#117542) refactor(ui): unify channel status and setup controls (#117499) fix(doctor): preserve surviving lint selections (#117543) fix(media): keep an unquoted MEDIA path with spaces as one media item (#112464) refactor(channels): consolidate lightweight plugin discovery (#117541) fix(imessage): prevent duplicate messages after delayed sends (#110853) refactor(memory): unify authoritative dreaming state and presentation (#117538) refactor(agents): consolidate main-session recovery ownership (#117383) fix(proxy-capture): make path-based session cleanup atomic (#98852) refactor(agents): consolidate compaction and context-engine ownership (#117482) fix(gateway): preserve Responses usage details (#117533) perf(gateway): skip empty session recovery stores (#117498) fix(ci): update canonical Kova performance pin (#117508) fix(system-agent): emit the wizard cancel hint once per message (#113731) refactor: dedupe secrets runtime snapshot fixtures (#117502) test(google): cover ready callback close precedence ...
* origin/main: (325 commits) fix(skills): preserve profile in ClawHub command hints (#117555) fix(cli): explain filtered plugin policy without unsafe recovery (#117556) fix(irc): strip markdown from outbound text (#112961) refactor(plugins): consolidate registry snapshots (#117561) fix(plugins): fail blocked enable commands (#117536) test(secrets): dedupe runtime state fixtures (#117563) feat(gateway): advertise chat attachment limits on hello-ok (#116188) fix(ui): preserve full graphemes in session owner initials (#117350) refactor(tui): consolidate runtime ownership (#117368) fix(update): return failure when dirty checkout blocks update (#117452) fix(auto-reply): apply mixed chat directives in one session transaction (#117542) refactor(ui): unify channel status and setup controls (#117499) fix(doctor): preserve surviving lint selections (#117543) fix(media): keep an unquoted MEDIA path with spaces as one media item (#112464) refactor(channels): consolidate lightweight plugin discovery (#117541) fix(imessage): prevent duplicate messages after delayed sends (#110853) refactor(memory): unify authoritative dreaming state and presentation (#117538) refactor(agents): consolidate main-session recovery ownership (#117383) fix(proxy-capture): make path-based session cleanup atomic (#98852) refactor(agents): consolidate compaction and context-engine ownership (#117482) ... # Conflicts: # extensions/xai/realtime-voice-bridge.ts
…openclaw#112464) Co-authored-by: MatthewSynthia <[email protected]>
* origin/main: (26 commits) fix(update): return failure when dirty checkout blocks update (openclaw#117452) fix(auto-reply): apply mixed chat directives in one session transaction (openclaw#117542) refactor(ui): unify channel status and setup controls (openclaw#117499) fix(doctor): preserve surviving lint selections (openclaw#117543) fix(media): keep an unquoted MEDIA path with spaces as one media item (openclaw#112464) refactor(channels): consolidate lightweight plugin discovery (openclaw#117541) fix(imessage): prevent duplicate messages after delayed sends (openclaw#110853) refactor(memory): unify authoritative dreaming state and presentation (openclaw#117538) refactor(agents): consolidate main-session recovery ownership (openclaw#117383) fix(proxy-capture): make path-based session cleanup atomic (openclaw#98852) refactor(agents): consolidate compaction and context-engine ownership (openclaw#117482) fix(gateway): preserve Responses usage details (openclaw#117533) perf(gateway): skip empty session recovery stores (openclaw#117498) fix(ci): update canonical Kova performance pin (openclaw#117508) fix(system-agent): emit the wizard cancel hint once per message (openclaw#113731) refactor: dedupe secrets runtime snapshot fixtures (openclaw#117502) test(google): cover ready callback close precedence test(openai): dedupe realtime voice fixtures (openclaw#117503) fix(google): flush lazy prompts on provider readiness fix(gateway): keep canonical hooks on pristine startup path (openclaw#117493) ...
* origin/main: (35 commits) fix(update): return failure when dirty checkout blocks update (openclaw#117452) fix(auto-reply): apply mixed chat directives in one session transaction (openclaw#117542) refactor(ui): unify channel status and setup controls (openclaw#117499) fix(doctor): preserve surviving lint selections (openclaw#117543) fix(media): keep an unquoted MEDIA path with spaces as one media item (openclaw#112464) refactor(channels): consolidate lightweight plugin discovery (openclaw#117541) fix(imessage): prevent duplicate messages after delayed sends (openclaw#110853) refactor(memory): unify authoritative dreaming state and presentation (openclaw#117538) refactor(agents): consolidate main-session recovery ownership (openclaw#117383) fix(proxy-capture): make path-based session cleanup atomic (openclaw#98852) refactor(agents): consolidate compaction and context-engine ownership (openclaw#117482) fix(gateway): preserve Responses usage details (openclaw#117533) perf(gateway): skip empty session recovery stores (openclaw#117498) fix(ci): update canonical Kova performance pin (openclaw#117508) fix(system-agent): emit the wizard cancel hint once per message (openclaw#113731) refactor: dedupe secrets runtime snapshot fixtures (openclaw#117502) test(google): cover ready callback close precedence test(openai): dedupe realtime voice fixtures (openclaw#117503) fix(google): flush lazy prompts on provider readiness fix(gateway): keep canonical hooks on pristine startup path (openclaw#117493) ...
* origin/main: (491 commits) feat(gateway): advertise chat attachment limits on hello-ok (openclaw#116188) fix(ui): preserve full graphemes in session owner initials (openclaw#117350) refactor(tui): consolidate runtime ownership (openclaw#117368) fix(update): return failure when dirty checkout blocks update (openclaw#117452) fix(auto-reply): apply mixed chat directives in one session transaction (openclaw#117542) refactor(ui): unify channel status and setup controls (openclaw#117499) fix(doctor): preserve surviving lint selections (openclaw#117543) fix(media): keep an unquoted MEDIA path with spaces as one media item (openclaw#112464) refactor(channels): consolidate lightweight plugin discovery (openclaw#117541) fix(imessage): prevent duplicate messages after delayed sends (openclaw#110853) refactor(memory): unify authoritative dreaming state and presentation (openclaw#117538) refactor(agents): consolidate main-session recovery ownership (openclaw#117383) fix(proxy-capture): make path-based session cleanup atomic (openclaw#98852) refactor(agents): consolidate compaction and context-engine ownership (openclaw#117482) fix(gateway): preserve Responses usage details (openclaw#117533) perf(gateway): skip empty session recovery stores (openclaw#117498) fix(ci): update canonical Kova performance pin (openclaw#117508) fix(system-agent): emit the wizard cancel hint once per message (openclaw#113731) refactor: dedupe secrets runtime snapshot fixtures (openclaw#117502) test(google): cover ready callback close precedence ...
* origin/main: (325 commits) fix(skills): preserve profile in ClawHub command hints (openclaw#117555) fix(cli): explain filtered plugin policy without unsafe recovery (openclaw#117556) fix(irc): strip markdown from outbound text (openclaw#112961) refactor(plugins): consolidate registry snapshots (openclaw#117561) fix(plugins): fail blocked enable commands (openclaw#117536) test(secrets): dedupe runtime state fixtures (openclaw#117563) feat(gateway): advertise chat attachment limits on hello-ok (openclaw#116188) fix(ui): preserve full graphemes in session owner initials (openclaw#117350) refactor(tui): consolidate runtime ownership (openclaw#117368) fix(update): return failure when dirty checkout blocks update (openclaw#117452) fix(auto-reply): apply mixed chat directives in one session transaction (openclaw#117542) refactor(ui): unify channel status and setup controls (openclaw#117499) fix(doctor): preserve surviving lint selections (openclaw#117543) fix(media): keep an unquoted MEDIA path with spaces as one media item (openclaw#112464) refactor(channels): consolidate lightweight plugin discovery (openclaw#117541) fix(imessage): prevent duplicate messages after delayed sends (openclaw#110853) refactor(memory): unify authoritative dreaming state and presentation (openclaw#117538) refactor(agents): consolidate main-session recovery ownership (openclaw#117383) fix(proxy-capture): make path-based session cleanup atomic (openclaw#98852) refactor(agents): consolidate compaction and context-engine ownership (openclaw#117482) ... # Conflicts: # extensions/xai/realtime-voice-bridge.ts
Fixes #112421
Original contributor: @MatthewSynthia. Original issue reporter: @Ali-Al1. The contributor's original human Git author, email, first authored timestamp, and PR are preserved.
What Problem This Solves
Legacy final assistant replies with an unquoted
MEDIA:attachment whose actual local pathname contains spaces silently split that one image into nonexistent/unsafe fragments. The fragments then reach reply normalization, outbound payload planning, and the real local media loader, so the user loses the generated image. Two spaced attachments on the same directive can both be lost. Windows profile names and UNC paths are affected as well.Why This Change Was Made
Group whitespace-separated fragments at the canonical
src/media/parse.tsdirective parser only while they still belong to the same rooted local source. Preserve original whitespace; stop at an independent drive, absolute/home/relative root, URL/file scheme, or independently valid completed attachment. Validate grouped paths with the existing security owner, and never absorb traversal or a rejected loopback URL into an approved attachment.Refresh the contributor's implementation onto current main and remove the unrelated bundled relay file. The exact branch now changes only
src/media/parse.tsand its colocated owner test. Production delta is +31 lines; there is no dependency, config, public API, or channel-specific behavior change.User Impact
One or multiple real image files in directories or filenames containing spaces now survive the entire parser -> reply normalization -> outbound payload -> real local file loading path. Quoted inputs remain unchanged, independent attachments remain separate, Windows drives/UNC paths retain their full spelling, and traversal/SSRF rejection remains enforced.
Evidence
The exact same real proof creates two real 68-byte PNGs in separate spaced directories, invokes production
splitMediaFromOutput,normalizeReplyPayloadDirectives,createOutboundPayloadPlan, andloadWebMediawith the real allowlisted directory, and compares every loaded byte.Before, current main:
[ { "scenario": "single-png", "caption": "Image ready\nfinal.png", "parsed": [ "<temp-root>/My", "Files/Project", "Assets/render" ], "reply": [ "<temp-root>/My", "Files/Project", "Assets/render" ], "outbound": [ [ "<temp-root>/My", "Files/Project", "Assets/render" ] ], "loaded": [ { "path": "<temp-root>/My", "error": "not-found" }, { "path": "Files/Project", "error": "path-not-allowed" }, { "path": "Assets/render", "error": "path-not-allowed" } ] }, { "scenario": "two-png", "caption": "Images ready\nfinal.png photo.png", "parsed": [ "<temp-root>/My", "Files/Project", "Assets/render", "<temp-root>/Second", "Album/another" ], "reply": [ "<temp-root>/My", "Files/Project", "Assets/render", "<temp-root>/Second", "Album/another" ], "outbound": [ [ "<temp-root>/My", "Files/Project", "Assets/render", "<temp-root>/Second", "Album/another" ] ], "loaded": [ { "path": "<temp-root>/My", "error": "not-found" }, { "path": "Files/Project", "error": "path-not-allowed" }, { "path": "Assets/render", "error": "path-not-allowed" }, { "path": "<temp-root>/Second", "error": "not-found" }, { "path": "Album/another", "error": "path-not-allowed" } ] }, { "scenario": "windows-traversal", "text": "Last\\..\\secret.png", "parsed": [ "C:\\Users\\First" ] }, { "scenario": "posix-traversal", "text": "screenshots/../../.env", "parsed": [ "/tmp/project" ] }, { "scenario": "blocked-ssrf", "text": "https://127.0.0.1/secret.png", "parsed": [ "C:\\Users\\First", "Last\\workspace\\shot.png" ] } ]After, exact contributor head
bdc22d78c1cde863e7ee3b2863bdbf777f8766c8:[ { "scenario": "single-png", "caption": "Image ready", "parsed": [ "<temp-root>/My Files/Project Assets/render final.png" ], "reply": [ "<temp-root>/My Files/Project Assets/render final.png" ], "outbound": [ [ "<temp-root>/My Files/Project Assets/render final.png" ] ], "loaded": [ { "path": "<temp-root>/My Files/Project Assets/render final.png", "kind": "image", "bytes": 68, "exactBytes": true } ] }, { "scenario": "two-png", "caption": "Images ready", "parsed": [ "<temp-root>/My Files/Project Assets/render final.png", "<temp-root>/Second Album/another photo.png" ], "reply": [ "<temp-root>/My Files/Project Assets/render final.png", "<temp-root>/Second Album/another photo.png" ], "outbound": [ [ "<temp-root>/My Files/Project Assets/render final.png", "<temp-root>/Second Album/another photo.png" ] ], "loaded": [ { "path": "<temp-root>/My Files/Project Assets/render final.png", "kind": "image", "bytes": 68, "exactBytes": true }, { "path": "<temp-root>/Second Album/another photo.png", "kind": "image", "bytes": 68, "exactBytes": true } ] }, { "scenario": "quoted-png", "caption": "Quoted image", "parsed": [ "<temp-root>/My Files/Project Assets/render final.png" ], "reply": [ "<temp-root>/My Files/Project Assets/render final.png" ], "outbound": [ [ "<temp-root>/My Files/Project Assets/render final.png" ] ], "loaded": [ { "path": "<temp-root>/My Files/Project Assets/render final.png", "kind": "image", "bytes": 68, "exactBytes": true } ] }, { "scenario": "windows-two", "text": "", "parsed": [ "C:\\Users\\First Last\\workspace\\shot.png", "D:\\Other User\\second.png" ] }, { "scenario": "windows-relative", "text": "", "parsed": [ "C:\\Users\\First Last\\workspace\\shot.png", "media/second.png" ] }, { "scenario": "unc", "text": "", "parsed": [ "\\\\server\\My Files\\Project Assets\\render final.png" ] }, { "scenario": "windows-traversal", "text": "", "parsed": [] }, { "scenario": "posix-traversal", "text": "", "parsed": [] }, { "scenario": "traversal-plus-safe", "text": "", "parsed": [ "/tmp/safe/second.png" ] }, { "scenario": "blocked-ssrf", "text": "https://127.0.0.1/secret.png", "parsed": [ "C:\\Users\\First Last\\workspace\\shot.png" ] } ]All three owner/caller suites pass: 158 tests across two Vitest shards. Targeted oxfmt and
git diff --checkpass. Fresh Codex Sol xhigh structured autoreview is clean. Both latest ClawSweeper rank-up moves are satisfied: current-main refresh plus focused parser proof, and complete removal of the unrelated relay change.