[OPIK-6871] [SDK] fix: ignore media:// authority URIs in local media extraction#126
Draft
JetoPistola wants to merge 2 commits into
Draft
[OPIK-6871] [SDK] fix: ignore media:// authority URIs in local media extraction#126JetoPistola wants to merge 2 commits into
JetoPistola wants to merge 2 commits into
Conversation
…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>
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>
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.
User description
Details
OpenClaw
media://inbound/...URIs were being treated as local absolute file paths. Themedia:local-path regex inmedia.tsallowed a leading/, somedia://inbound/example.jpgmatched and was normalized to/inbound/example.jpg. The attachment uploader thenstat'd that non-existent path and logged anENOENTwarning, dropping the attachment.The fix adds a negative lookahead
(?!\/\/)aftermedia:so themedia://authority form is no longer captured. Legitimate local references —media:/abs/path.jpgandmedia:~/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
Issues
Testing
Added two regression tests in
src/service/media.test.ts:media://inbound/example.jpg(exact issue repro) collects nothingmedia://host/path/to/example.jpg(authority + host segment) collects nothingExisting positive cases (
media:/tmp/image.png,file://, markdown links) still pass. Full suite: 104 passed / 1 skipped;tsc --noEmitclean.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 somedia.tsno longer normalizes them and the attachment uploader stops treating them as files. Add regression tests forcollectMediaPathsFromStringand the uploader to ensure those URIs are skipped without warnings.MEDIA_SCHEME_LOCAL_PATH_REsomedia://authority URIs are excluded while localmedia:/paths remain normalized.Modified files (2)
Latest Contributors(2)
scheduleMediaAttachmentUploadsignoresmedia://authority URIs and never calls the attachments API or emits warnings.Modified files (1)
Latest Contributors(2)