Repository navigation
fix(discord): reject mismatched reply context - #114716
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 27, 2026, 4:20 PM ET / 20:20 UTC. ClawSweeper reviewWhat this changesThe PR treats a Discord nested reply payload whose ID differs from the message reference as invalid, replaces it with the canonical REST-fetched message, and omits reply context if that fetch fails. Merge readinessThis remains necessary: it addresses the open Discord native-reply regression by preventing stale nested reply text from becoming agent context. The proposed fail-closed behavior is bounded to mismatched payloads, has downstream context coverage, and the contributor supplied redacted real-Discord replay output; no discrete patch defect was established. Likely related person: pfrederiksen is the recent patch contributor, but historical ownership could not be established from the supplied review materials. Priority: P1 Review scores
Verification
How this fits togetherDiscord inbound messages are hydrated before OpenClaw builds the agent-visible message context. This change validates reply metadata at that hydration boundary, then either supplies the canonical referenced message or prevents unrelated reply text from reaching the agent envelope. flowchart LR
A[Discord inbound reply] --> B[Reply metadata check]
B -->|Nested message matches| C[Use nested reply]
B -->|Missing or mismatched| D[Fetch canonical reply]
D -->|Fetch succeeds| E[Hydrated canonical message]
D -->|Fetch fails after mismatch| F[Clear reply context]
C --> G[Agent message context]
E --> G
F --> G
Before merge
Agent review detailsSecurityNone. PR surfaceSource +22, Tests +102. Total +124 across 2 files. View PR surface stats
Review metricsNone. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep validation at the Discord hydration boundary, preserve the canonical-fetch-or-clear rule for mismatched reply data, and merge only after the branch is refreshed against current main and normal Discord-owner review confirms the fail-closed tradeoff. Do we have a high-confidence way to reproduce the issue? Yes—source inspection from the supplied diff gives a high-confidence path: current behavior only distinguishes missing nested payloads, so a present mismatched payload can reach the downstream reply-context builder; the new regression tests directly cover that path. Is this the best way to solve the issue? Yes. Validating the identifier at the existing Discord hydration boundary is narrower and safer than adding defensive checks in later context projections, because all consumers then receive either canonical reply data or no reply data. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 762f04da5abc. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (2 earlier review cycles)
|
94668ca to
21221e1
Compare
|
@clawsweeper re-review Addressed the proof and downstream-contract concerns on rebased head
|
|
🦞👀 Command router queued. I will update this comment with the next step. |
|
Added the requested redacted proof from a real Discord setup. Method: captured a real native reply plus canonical and unrelated messages from the active Discord channel through OpenClaw’s Discord connector, injected the unrelated captured message as stale nested context, and ran that capture through the patched hydration and agent-context path. IDs and content were redacted/hashes only. {
"source": "redacted live Discord connector capture + patched hydration/context path",
"canonicalFetchCalls": ["/channels/<redacted-id>/messages/<redacted-id>"],
"success": {
"replyToIdMatchesCanonical": true,
"replyToBodyDigest": "8f9b1c031dbf",
"staleBodyExcluded": true
},
"fetchFailure": {
"replyToIdOmitted": true,
"replyToBodyOmitted": true
}
}The live capture was not committed and contained no credentials. The PR Evidence section now records this proof. @clawsweeper re-review |
|
🦞👀 Command router queued. I will update this comment with the next step. |
|
Merged via squash.
|
* fix(discord): reject mismatched reply context * test(discord): prove safe reply context propagation
* origin/main: (561 commits) refactor(plugins): reuse prepared channel discovery (openclaw#114942) fix(discord): reject mismatched reply context (openclaw#114716) fix(auto-reply): keep fast approval result private fix(auto-reply): satisfy approval boundary checks fix(imessage): unblock text approval fallback fix(imessage): keep approval test resets internal fix(gateway): narrow channel approval runtime types fix(imessage): resolve approval controls safely fix(imessage): harden native approval polls feat(imessage): add native poll approval controls fix(mac): bound node worker crash retries (openclaw#114974) fix(channels): keep running-channel connectivity tri-state (openclaw#114970) feat(ui): expand the Lobsterdex with 14 palettes, lore tooltips, and a collection page (openclaw#114959) fix(agents): honor models.providers auth mode pin in credential eligibility (openclaw#114944) fix(apps): fence stale mobile delivery state test(pr): provide ripgrep surface in review harness (openclaw#114958) fix(code-mode): bound and simplify worker lifecycles (openclaw#114945) fix(mattermost): prevent hook-controlled preview leaks fix(tool-display): avoid recursive search summaries (openclaw#114933) perf(catalog): memoize probes and single-flight identical list requests (openclaw#114961) ...
Summary
referenced_message.idmatchesmessage_reference.message_idWhat Problem This Solves
Discord reply turns can arrive with stale or mismatched nested referenced-message data. Trusting that payload allows an unrelated older message to be assembled as the current reply context.
This hardens the existing reply hydration path associated with #112650.
Evidence
pnpm test:changed— 1 shard, 9/9 tests passedpnpm check:changed— passed (format, policy guards, API contracts, extension and extension-test typechecks, lint, import cycles)21221e103f7d:replaces a mismatched nested reply with the canonical referenced messagepassed through the realMessagehydration andbuildDiscordMessageProcessContextpath.ReplyToId === "m0",ReplyToBody === "the canonical reply target", and thatReplyToBodyexcludes"unrelated older context".discards a mismatched nested reply when canonical hydration failspassed through the same downstream context builder and asserts bothReplyToIdandReplyToBodyare absent.Message.referencedMessagegetter readsrawData.referenced_message.buildDiscordMessageProcessContext.resolveReplyContextconsumes only the hydratedmessage.referencedMessage, so clearing an invalid nested payload prevents it from reaching the agent envelope.replyToIdMatchesCanonical: true,staleBodyExcluded: true, and a redacted canonical body digest.replyToIdOmitted: trueandreplyToBodyOmitted: true.Release note
Fixed Discord replies occasionally using unrelated stale message context when a referenced-message payload did not match the canonical reply target.