Skip to content

[Bug]: Uppercase file URI media directives are not extracted #103473

Description

@harjothkhara

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

MEDIA: directives using an uppercase FILE:// URI scheme are left in assistant text instead of being extracted as local media attachments.

Steps to reproduce

  1. Check out current main at f698703934f3c52d3e21f4b3f8d805c63f160845.
  2. Add the existing media-parser table case ['/tmp/generated.png', 'MEDIA:FILE:///tmp/generated.png'] to src/media/parse.test.ts.
  3. Run node scripts/run-vitest.mjs src/media/parse.test.ts with Node 24.
  4. Observe that splitMediaFromOutput returns visible text MEDIA:FILE:///tmp/generated.png and no extracted media URL.

Expected behavior

URI schemes are case-insensitive. MEDIA:FILE:///tmp/generated.png should normalize and extract the same local path as MEDIA:file:///tmp/generated.png: /tmp/generated.png.

Actual behavior

normalizeMediaSource checks src.startsWith('file://'), so the uppercase scheme is not removed. The remaining scheme-shaped value fails local-path validation and the directive stays in visible text.

Focused negative-control output:

FAIL src/media/parse.test.ts > splitMediaFromOutput > accepts supported media path variant: /tmp/generated.png
AssertionError: expected 'MEDIA:FILE:///tmp/generated.png' to be ''
Test Files  1 failed (1)
Tests       1 failed | 57 passed (58)

OpenClaw version

Current main at f698703934f3c52d3e21f4b3f8d805c63f160845.

Operating system

macOS 26.5 (Darwin), arm64.

Install method

Source checkout with the repository-pinned dependencies.

Model

Not applicable; reproduced directly through the production media parser.

Provider / routing chain

Not applicable; no provider or channel boundary is needed to reproduce the payload-shaping bug.

Logs

See the focused Vitest failure above.

Screenshots, recordings, and evidence

No visual surface is involved. The deterministic parser assertion captures the incorrect output value.

Impact and severity

Affected: any assistant/tool output that emits a valid file URI with non-lowercase scheme spelling.

Severity: low, but user-visible; the intended attachment is silently not delivered and the raw directive remains in the reply.

Frequency: deterministic for uppercase or mixed-case file:// schemes.

Consequence: generated local media is omitted from delivery.

Additional information

Live issue and PR searches for uppercase file URL MEDIA and normalizeMediaSource file:// found no open report or fix for case-insensitive file URI schemes. Closed #2878 covered Windows drive-path normalization after a lowercase file:// prefix, not scheme casing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions