fix(platform-id): trust pre-prefixed ids regardless of channel key#2654
Open
elancode wants to merge 1 commit into
Open
fix(platform-id): trust pre-prefixed ids regardless of channel key#2654elancode wants to merge 1 commit into
elancode wants to merge 1 commit into
Conversation
`namespacedPlatformId` previously only treated a value as already
prefixed when it started with `${channel}:`. When one chat-sdk
adapter is registered under a channel key that differs from its
SDK-emitted prefix (e.g. a second Telegram bot wired under channel
`telegram-2`, whose underlying chat-sdk still emits `telegram:<id>`),
the function double-prefixed the value into `telegram-2:telegram:<id>`
and downstream messaging_groups rows then failed to match any inbound.
Trust any `<lowercase-token>:` shape as already-encoded. Native
short-circuits (`@`, `+`, `group:`, `deltachat`) preserved.
Refs nanocoai#2653
Co-Authored-By: Claude Opus 4.7 (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.
What
namespacedPlatformId()now trusts any caller-supplied<prefix>:<id>value as the chat-sdk's already-encoded form, instead of only matching when the prefix equals the channel registry key.Why
When one chat-sdk adapter is registered under a channel key that differs from its SDK-side name (e.g. a second Telegram bot wired under channel
telegram-2, whose underlying@chat-adapter/telegramstill emitstelegram:<id>), the previous logic prepended the channel key on top, producingtelegram-2:telegram:<id>. That value never matches any real inbound platform_id, so messaging_groups created viascripts/init-first-agent.tsend up unreachable.How
raw.startsWith(${channel}:)exact match.^[a-z][a-z0-9_-]*:/iso any<lowercase-token>:…shape is trusted as already-encoded.@,+,group:,deltachat).Tests
Added
src/platform-id.test.tswith 6 cases covering bare ids, channel-matching prefix, non-matching prefix (the bug), WhatsApp / iMessage JIDs, Signal phone numbers / group ids, and DeltaChat numeric ids.Full suite (
pnpm test) — 338 passed, 0 failed.pnpm run build(tsc) — clean.Refs #2653