Skip to content

[OPIK-6871] [SDK] fix: ignore media:// authority URIs in local media extraction#126

Draft
JetoPistola wants to merge 2 commits into
mainfrom
danield/OPIK-6871-fix-media-inbound-uri-normalization
Draft

[OPIK-6871] [SDK] fix: ignore media:// authority URIs in local media extraction#126
JetoPistola wants to merge 2 commits into
mainfrom
danield/OPIK-6871-fix-media-inbound-uri-normalization

Conversation

@JetoPistola

@JetoPistola JetoPistola commented Jun 16, 2026

Copy link
Copy Markdown

User description

Details

image

OpenClaw media://inbound/... URIs were being treated as local absolute file paths. The media: local-path regex in media.ts allowed a leading /, so media://inbound/example.jpg matched and was normalized to /inbound/example.jpg. The attachment uploader then stat'd that non-existent path and logged an ENOENT warning, dropping the attachment.

The fix adds a negative lookahead (?!\/\/) after media: so the media:// authority form is no longer captured. Legitimate local references — media:/abs/path.jpg and media:~/path.jpg — still resolve unchanged.

Resolution via $OPENCLAW_STATE_DIR (the other option in the issue) was deliberately not taken: the codebase has no existing reference to that env var, the name itself arrived through a lossy sync, and adding that coupling would silently no-op if the name were wrong. media:// URIs are never local paths, so ignoring them is the correct fix regardless. Proper inbound-media resolution can follow once an OpenClaw state-dir contract is confirmed.

Change checklist

  • User facing
  • Documentation updated (if needed)
  • Tests added/updated (if needed)
  • Breaking changes documented (if any)

Issues

Testing

Added two regression tests in src/service/media.test.ts:

  • media://inbound/example.jpg (exact issue repro) collects nothing
  • media://host/path/to/example.jpg (authority + host segment) collects nothing

Existing positive cases (media:/tmp/image.png, file://, markdown links) still pass. Full suite: 104 passed / 1 skipped; tsc --noEmit clean.

Documentation

N/A



Generated description

Below is a concise technical summary of the changes proposed in this PR:
Ignore OpenClaw media:// authority references when detecting local media so media.ts no longer normalizes them and the attachment uploader stops treating them as files. Add regression tests for collectMediaPathsFromString and the uploader to ensure those URIs are skipped without warnings.

TopicDetails
Media URI parsing Add a negative lookahead to MEDIA_SCHEME_LOCAL_PATH_RE so media:// authority URIs are excluded while local media:/ paths remain normalized.
Modified files (2)
  • src/service/media.test.ts
  • src/service/media.ts
Latest Contributors(2)
UserCommitDate
danield@comet.com[OPIK-6871] [SDK] fix:...June 16, 2026
vincentkoc@ieee.orgRequire explicit local...March 06, 2026
Uploader guard Add behavior verification that scheduleMediaAttachmentUploads ignores media:// authority URIs and never calls the attachments API or emits warnings.
Modified files (1)
  • src/service/attachment-uploader.test.ts
Latest Contributors(2)
UserCommitDate
danield@comet.comtest(media): cover med...June 16, 2026
vincentkoc@ieee.orgRequire explicit local...March 06, 2026
Review this PR on Baz | Customize your next review

…extraction

OpenClaw media://inbound/... URIs were matched by the media: local-path
regex, which captured /inbound/... and led the attachment uploader to stat
a non-existent path (ENOENT). Add a negative lookahead so the media://
authority form is no longer treated as a local path, while media:/abs and
media:~/ references still resolve.

Implements OPIK-6871: media://inbound attachments are normalized to /inbound paths

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@JetoPistola JetoPistola marked this pull request as ready for review June 16, 2026 05:24
@JetoPistola JetoPistola self-assigned this Jun 16, 2026
@JetoPistola JetoPistola requested a review from alexkuzmik June 16, 2026 05:34
Add an integration test driving the real scheduleMediaAttachmentUploads
path with a media://inbound/... payload, asserting no upload is attempted
and no warning is emitted. Verified the test reproduces the original ENOENT
warning against the pre-fix regex, so it guards against regression of the
full extraction -> stat -> upload path, not just the regex in isolation.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@JetoPistola JetoPistola marked this pull request as draft June 18, 2026 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: media://inbound attachments are normalized to /inbound paths

1 participant