Skip to content

fix(agent-sdk): strip trailing colon from URL scheme in createRemoteAttachment - #4057

Open
ygd58 wants to merge 1 commit into
xmtp:mainfrom
ygd58:fix/attachment-scheme-trailing-colon
Open

ygd58 wants to merge 1 commit into
xmtp:mainfrom
ygd58:fix/attachment-scheme-trailing-colon

Conversation

@ygd58

@ygd58 ygd58 commented Sep 4, 2026

Copy link
Copy Markdown

Fixes #4034

createRemoteAttachment() stored url.protocol directly as the remote attachment scheme. URL.protocol includes the trailing colon (e.g. "https:"), but the rest of libxmtp's remote attachment tests and content type examples consistently use the scheme without it (e.g. "https") - bindings/node/test/RemoteAttachmentEncryption.test.ts, bindings/wasm/test/RemoteAttachmentEncryption.test.ts, bindings/wasm/test/EnrichedMessage.test.ts, and crates/xmtp_content_types/src/remote_attachment.rs.

Fix: strip the trailing colon with url.protocol.replace(/:$/, ""), matching the suggested fix in the issue.

Tests: added a regression test asserting the scheme for both https and http URLs. Verified it fails against the pre-fix code (expected 'https:' to be 'https') and passes against the fix, via a full native build (cargo build for bindings/node, then yarn build for node-sdk, since agent-sdk's test suite imports encryptAttachment from @xmtp/node-sdk, which requires the compiled native binding).

Verified locally: vitest run src/util/AttachmentUtil.test.ts - 3/3 passing, typecheck, eslint, and prettier clean on both changed files.

Note

Strip trailing colon from URL scheme in createRemoteAttachment

URL.protocol returns a trailing colon (e.g. https:), which was being stored as the attachment scheme. The fix removes that colon so schemes like https and http are stored cleanly. Tests now assert scheme normalization for both HTTPS and HTTP URLs.

Macroscope summarized fd9db85.

…ttachment

Fixes xmtp#4034

createRemoteAttachment() stored url.protocol directly as the remote
attachment scheme. URL.protocol includes the trailing colon (e.g.
"https:"), but the rest of libxmtp's remote attachment tests and
content type examples consistently use the scheme without it (e.g.
"https") - bindings/node/test/RemoteAttachmentEncryption.test.ts,
bindings/wasm/test/RemoteAttachmentEncryption.test.ts,
bindings/wasm/test/EnrichedMessage.test.ts, and
crates/xmtp_content_types/src/remote_attachment.rs.

Strip the trailing colon with url.protocol.replace(/:$/, ""), matching
the suggested fix in the issue.

Added a regression test asserting the scheme for both https and http
URLs. Verified it fails against the pre-fix code (expected 'https:' to
be 'https') and passes against the fix, via a full native build
(cargo build for bindings/node, then yarn build for node-sdk, since
agent-sdk's test suite imports encryptAttachment from @xmtp/node-sdk
which requires the compiled native binding).

yarn vitest run src/util/AttachmentUtil.test.ts - 3/3 passing. yarn
typecheck, eslint, and prettier clean on both changed files.
@ygd58
ygd58 requested a review from a team as a code owner September 4, 2026 04:33
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.

fix(agent-sdk): strip trailing colon from URL scheme in createRemoteAttachment

2 participants