Skip to content

fix(media): keep an unquoted MEDIA path with spaces as one media item - #112464

Merged
steipete merged 1 commit into
openclaw:mainfrom
MatthewSynthia:fix/media-spaced-path
Aug 1, 2026
Merged

steipete merged 1 commit into
openclaw:mainfrom
MatthewSynthia:fix/media-spaced-path

Conversation

@MatthewSynthia

@MatthewSynthia MatthewSynthia commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

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.ts directive 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.ts and 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, and loadWebMedia with 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"
    ]
  }
]
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 xhigh

All three owner/caller suites pass: 158 tests across two Vitest shards. Targeted oxfmt and git diff --check pass. 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.

@MatthewSynthia
MatthewSynthia force-pushed the fix/media-spaced-path branch from baf76fe to f3725ea Compare July 25, 2026 01:22
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Jul 25, 2026
@clawsweeper

clawsweeper Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed August 1, 2026, 1:45 PM ET / 17:45 UTC.

ClawSweeper review

What this changes

The PR changes unquoted MEDIA: parsing so local paths containing spaces remain a single media item while independent attachments and rejected sources remain distinct.

Merge readiness

⚠️ Needs maintainer review before merge - 2 items remain

Keep 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
Reviewed head: bdc22d78c1cde863e7ee3b2863bdbf777f8766c8

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The real attachment proof is strong, but a focused parser-boundary omission still blocks merge readiness.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR contains maintainer-recorded after-fix live output showing real spaced PNGs survive parser, reply, outbound-plan, and local-loader stages with exact-byte checks; redact local paths and other private details in any future proof updates.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR contains maintainer-recorded after-fix live output showing real spaced PNGs survive parser, reply, outbound-plan, and local-loader stages with exact-byte checks; redact local paths and other private details in any future proof updates.
Evidence reviewed 6 items Branch boundary omission: The new collapsing loop only joins a continuation when the preceding fragment begins with an absolute/home/drive/UNC root. Relative paths such as media/First Album/one.png never enter that branch, although they are otherwise accepted local media syntax.
Relative-path contract: Current media validation accepts non-scheme references containing / or \\ as local paths, so media/First and Album/one.png are independently valid fragments rather than invalid leftovers that the fallback can reunite.
Missing regression shape: The added multi-item cases cover relative paths without spaces and rooted paths with spaces, but not two relative paths that both contain spaces; that exact combination statically yields four media references instead of the intended two.
Findings 1 actionable finding [P2] Handle spaced relative media sources
Security None None.

How this fits together

Assistant output is parsed for legacy MEDIA: directives, then the resulting media references flow through reply normalization and outbound payload planning to the local or remote media loader. This PR changes the parser that establishes those attachment boundaries for every downstream delivery surface.

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]
Loading

Before merge

  • Handle spaced relative media sources (P2) - The new join condition only applies after an absolute/home/drive/UNC fragment. For MEDIA:media/First Album/one.png media/Second Album/two.png, the four whitespace tokens remain separate; each is accepted as a relative local path, so the parser returns four attachments instead of two. Extend the grouping rule to supported relative local paths and add this regression case.
  • Resolve merge risk (P1) - Merging now still turns MEDIA:media/First Album/one.png media/Second Album/two.png into four attachment references, so generated relative media in spaced directories can remain misdelivered even though rooted examples work.

Findings

  • [P2] Handle spaced relative media sources — src/media/parse.ts:215-217
Agent review details

Security

None.

PR surface

Source +31, Tests +61. Total +92 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 34 3 +31
Tests 1 61 0 +61
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 95 3 +92

Review metrics

None.

Merge-risk options

Maintainer options:

  1. Cover relative spaced media paths (recommended)
    Update the parser and its focused tests so two relative local paths containing spaces remain two attachments without weakening traversal or remote-URL rejection.
  2. Constrain the supported syntax
    If maintainers intentionally support unquoted spaces only for rooted sources, narrow the PR claim and document that relative paths with spaces must be quoted.

Technical review

Best 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: MEDIA:media/First Album/one.png media/Second Album/two.png bypasses the rooted-only join and each fragment satisfies the existing relative-local-path validator, producing four references rather than two.

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:

  • [P2] Handle spaced relative media sources — src/media/parse.ts:215-217
    The new join condition only applies after an absolute/home/drive/UNC fragment. For MEDIA:media/First Album/one.png media/Second Album/two.png, the four whitespace tokens remain separate; each is accepted as a relative local path, so the parser returns four attachments instead of two. Extend the grouping rule to supported relative local paths and add this regression case.
    Confidence: 0.96

Overall correctness: patch is incorrect
Overall confidence: 0.94

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (live_output): The PR contains maintainer-recorded after-fix live output showing real spaced PNGs survive parser, reply, outbound-plan, and local-loader stages with exact-byte checks; redact local paths and other private details in any future proof updates.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove status: 👀 ready for maintainer look: Current PR status label is status: ⏳ waiting on author.

Label justifications:

  • P1: This fixes and still partially exposes a visible attachment-delivery failure on valid local media paths.
  • merge-risk: 🚨 message-delivery: The parser decides whether whitespace denotes one path or multiple attachments, so an incomplete boundary rule can misroute or split media on delivery.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (live_output): The PR contains maintainer-recorded after-fix live output showing real spaced PNGs survive parser, reply, outbound-plan, and local-loader stages with exact-byte checks; redact local paths and other private details in any future proof updates.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR contains maintainer-recorded after-fix live output showing real spaced PNGs survive parser, reply, outbound-plan, and local-loader stages with exact-byte checks; redact local paths and other private details in any future proof updates.

Evidence

Acceptance criteria:

  • [P1] node scripts/run-vitest.mjs src/media/parse.test.ts.
  • [P1] node scripts/run-vitest.mjs src/auto-reply/reply/reply-delivery.test.ts src/infra/outbound/payloads.test.ts.
  • [P1] git diff --check.

What I checked:

  • Branch boundary omission: The new collapsing loop only joins a continuation when the preceding fragment begins with an absolute/home/drive/UNC root. Relative paths such as media/First Album/one.png never enter that branch, although they are otherwise accepted local media syntax. (src/media/parse.ts:215, bdc22d78c1cd)
  • Relative-path contract: Current media validation accepts non-scheme references containing / or \ as local paths, so media/First and Album/one.png are independently valid fragments rather than invalid leftovers that the fallback can reunite. (src/media/parse.ts:98, 5118b0b915c0)
  • Missing regression shape: The added multi-item cases cover relative paths without spaces and rooted paths with spaces, but not two relative paths that both contain spaces; that exact combination statically yields four media references instead of the intended two. (src/media/parse.test.ts:98, bdc22d78c1cd)
  • Real behavior proof: A maintainer comment records an after-fix run that created two real PNGs, passed them through parsing, reply normalization, outbound planning, and the real local media loader, and compared the loaded bytes. The downloaded manifest only contains the intentionally blocked loopback-URL artifact, whose download failure is expected for that rejected-security scenario. (bdc22d78c1cd)
  • Current-main provenance: The current parser validation and path-classification block traces to the recent main commit below, making Peter Steinberger the strongest current-history routing candidate for the shared media-parser contract. (src/media/parse.ts:88, 1e34c2d073eb)
  • Current main does not contain this fix: The PR head is a child of current-main parser commit 1e34c2d073; its parser changes are not present at the checked-out main SHA, so this work is neither implemented nor superseded on main. (src/media/parse.ts:52, bdc22d78c1cd)

Likely related people:

  • Peter Steinberger: Current-main blame attributes the parser validation and local-path classification that define this PR's grouping boundary to his recent media-parser refactor. (role: recent media-parser contributor; confidence: high; commits: 1e34c2d073eb; files: src/media/parse.ts)

Rank-up moves

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

  • Add and pass a regression covering two relative local paths that each contain spaces.
  • Repeat the supplied parser-to-loader proof for that new case and include the redacted output.

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 (7 earlier review cycles)
  • reviewed 2026-07-25T01:28:50.197Z sha f3725ea115b909dff3a9e50a01525d80ead86e16 :: needs changes before merge. :: [P1] Preserve relative multi-media directives
  • reviewed 2026-07-26T22:08:44.239Z sha ce31d5363afa0d46adb9608e2c3bb938e20db383 :: needs changes before merge. :: [P1] Preserve mixed absolute and relative media directives
  • reviewed 2026-07-27T18:02:00.085Z sha f50ecb0807452291a5aa00b6737238b28e2bb0f3 :: needs changes before merge. :: [P2] Avoid using filename extensions as media boundaries
  • reviewed 2026-07-28T00:52:06.723Z sha f50ecb0807452291a5aa00b6737238b28e2bb0f3 :: needs changes before merge. :: [P2] Remove the filename-extension media boundary
  • reviewed 2026-07-29T18:40:40.661Z sha fa23db1687a523c6f0ba3b3994de4b0996edf171 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-01T05:56:22.947Z sha fa23db1687a523c6f0ba3b3994de4b0996edf171 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-01T06:41:00.087Z sha fa23db1687a523c6f0ba3b3994de4b0996edf171 :: needs maintainer review before merge. :: none

@MatthewSynthia
MatthewSynthia force-pushed the fix/media-spaced-path branch 2 times, most recently from ce31d53 to f50ecb0 Compare July 27, 2026 17:55
@MatthewSynthia

Copy link
Copy Markdown
Contributor Author

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 (/home/u/my), whereas a genuine mixed list has every fragment ending in a media file — so those stay split. beginsNewMediaRoot() alone missed this because a valid relative later source (media/b.png) isn't rooted.

         !unwrapped &&
         parts.length > 1 &&
+        !parts.every((part) => HAS_FILE_EXT.test(cleanCandidate(part))) &&
         /\s/.test(payloadValue) &&

Real-behavior proof — the actual splitMediaFromOutput parser, before/after:

Input Before (ce31d536) After (f50ecb08)
MEDIA:/tmp/a.png media/b.png (mixed) ❌ 1 — ["/tmp/a.png media/b.png"] ✅ 2 — ["/tmp/a.png","media/b.png"]
MEDIA:/home/user/my folder/shot.png (single spaced path, control) ✅ 1 ✅ 1 (no #112421 regression)
MEDIA:media/a.png media/b.png (relative multi, control) ✅ 2 ✅ 2

Regression test added (keeps a mixed absolute + relative multi-media directive as separate items); full parse.test.ts is 65/65 green.

@MatthewSynthia
MatthewSynthia marked this pull request as ready for review July 28, 2026 00:46
@clawsweeper clawsweeper Bot added 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. and removed 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 Jul 29, 2026
@steipete

steipete commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Maintainer real attachment-delivery verification

Preserved 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 bdc22d78c1cde863e7ee3b2863bdbf777f8766c8 changes exactly two media owner files (+31 production lines).

Created two real PNG files in directories and filenames containing spaces, then exercised production splitMediaFromOutput -> normalizeReplyPayloadDirectives -> createOutboundPayloadPlan -> real loadWebMedia with its actual allowed-directory boundary.

Before: the one-image reply produced three invalid attachment fragments; two images produced five invalid fragments. The real loader returned not-found / path-not-allowed; Windows and POSIX traversal fragments also leaked.

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 xhigh

158 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.

@clawsweeper clawsweeper Bot added 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. and removed 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 1, 2026
@steipete
steipete merged commit 8206a0c into openclaw:main Aug 1, 2026
134 of 142 checks passed
@steipete

steipete commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

vincentkoc added a commit that referenced this pull request Aug 1, 2026
* 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)
  ...
abdulrahman305 pushed a commit to qenex-ai/openclaw that referenced this pull request Aug 1, 2026
* 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)
  ...
vincentkoc added a commit that referenced this pull request Aug 1, 2026
* 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
  ...
vincentkoc added a commit that referenced this pull request Aug 1, 2026
* 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
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 2, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 2, 2026
* 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)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 2, 2026
* 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)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 2, 2026
* 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
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 2, 2026
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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.

MEDIA: directive fails for paths containing spaces (e.g. Windows profile "C:\Users\First Last")

2 participants