fix(discord): parse provider-prefixed channel targets#78625
fix(discord): parse provider-prefixed channel targets#78625Patrick-Erichsen merged 2 commits intomainfrom
Conversation
|
Codex review: needs real behavior proof before merge. Summary Reproducibility: yes. by source inspection: current main parses Real behavior proof Next step before merge Security Review findings
Review detailsBest possible solution: Either retarget this PR to only provider-prefixed Discord channel parsing without closing the linked DM bug, or expand it to fix the actual allowFrom-aware bare numeric DM path with regression tests, a corrected changelog line, and real runtime proof. Do we have a high-confidence way to reproduce the issue? Yes by source inspection: current main parses Is this the best way to solve the issue? No. Parsing provider-prefixed channel/user targets before the legacy shorthand is a good narrow fix for one misparse, but it is not sufficient to solve the linked Full review comments:
Overall correctness: patch is incorrect What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 97b07eaeaf38. |
4fc630f to
72fd4ff
Compare
c06f137 to
fca15d4
Compare
* fix(discord): parse provider-prefixed channel targets * fix(discord): resolve allowlisted numeric dm targets (cherry picked from commit 5135662)
|
Regression still present in v2026.5.7: Outbound-initiated
Original issue: #78572 |
* fix(discord): parse provider-prefixed channel targets * fix(discord): resolve allowlisted numeric dm targets
* fix(discord): parse provider-prefixed channel targets * fix(discord): resolve allowlisted numeric dm targets
Summary
user:<id>instead of being treated as channels.discord:<id>DM shorthand, sodiscord:channel:<id>remains a channel target.discord:<userId>direct-message routing.Fixes #78572.
Real behavior proof
Behavior addressed: Discord
message(action="send")target resolution for the #78572 repro shape: a bare numeric Discord user ID that appears inchannels.discord.allowFrommust route asuser:<id>for DM delivery, not aschannel:<id>. Also verifies provider-prefixeddiscord:channel:<id>routes as a channel target and can deliver a real Discord channel message.Real environment tested: Local OpenClaw CLI built from this PR branch on macOS, using a temporary
OPENCLAW_HOME/XDG_CONFIG_HOMEand a temp Discord config with the local Discord bot token provided throughDISCORD_BOT_TOKEN. The live channel delivery target was Discord channel1501672157829140502.Exact steps or command run after the patch:
channels.discord.enabled=true,channels.discord.token={ source: "env", provider: "default", id: "DISCORD_BOT_TOKEN" }, andchannels.discord.allowFrom=["*"].pnpm openclaw message send --channel discord --target "discord:channel:1501672157829140502" --message "OpenClaw live Discord delivery check for PR 78625 2026-05-06T21:25:34Z" --json.channels.discord.allowFrom=["1439091261670948987"]:pnpm openclaw message send --channel discord --target "1439091261670948987" --message "dry-run allowFrom DM target check" --dry-run --json.Evidence after fix:
Live Discord channel delivery returned:
{ "action": "send", "channel": "discord", "dryRun": false, "handledBy": "core", "payload": { "channel": "discord", "to": "channel:1501672157829140502", "via": "direct", "result": { "messageId": "1501696468438880377", "channel": "discord", "receipt": { "primaryPlatformMessageId": "1501696468438880377", "parts": [ { "platformMessageId": "1501696468438880377", "kind": "text", "raw": { "channel": "discord", "messageId": "1501696468438880377", "channelId": "1501672157829140502" } } ] } } } }The #78572 bare numeric allowlisted DM dry-run returned:
{ "action": "send", "channel": "discord", "dryRun": true, "handledBy": "core", "payload": { "channel": "discord", "to": "user:1439091261670948987", "via": "direct", "mediaUrl": null, "dryRun": true } }Observed result after fix: The provider-prefixed Discord channel target delivered a real Discord message with platform message id
1501696468438880377, and the #78572 bare numeric allowlisted Discord target resolves touser:1439091261670948987, which is the DM send target expected by Discord instead ofchannel:<id>.What was not tested: Live Discord DM delivery to the #78572 reporter's user id was not run because we do not have that user's bot/channel relationship locally; the DM fix was verified at the target-resolution layer that produced the reported
Unknown Channelmisroute, and live channel delivery verified the Discord send path after provider-prefixed normalization.Verification
pnpm exec oxfmt --check --threads=1 extensions/discord/src/channel.ts extensions/discord/src/channel.test.ts extensions/discord/src/target-parsing.ts extensions/discord/src/normalize.ts extensions/discord/src/targets.test.ts extensions/discord/src/outbound-adapter.test.ts extensions/discord/src/outbound-session-route.test.ts CHANGELOG.mdpnpm test extensions/discord/src/channel.test.ts extensions/discord/src/targets.test.ts extensions/discord/src/normalize.test.ts extensions/discord/src/outbound-adapter.test.ts extensions/discord/src/outbound-session-route.test.ts src/agents/tools/message-tool.test.ts -- --run