Skip to content

fix(discord): prevent accidental mentions inside unfinished code - #129338

Merged
steipete merged 2 commits into
mainfrom
codex/qa-discord-inline-code-mentions-20260825
Aug 25, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/qa-discord-inline-code-mentions-20260825

Conversation

@steipete

@steipete steipete commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Discord rewrites a harmless name inside unfinished inline Markdown code into a real native user mention, generating an unintended notification through both ordinary bot messages and persona webhooks.

Why This Change Was Made

The Discord mention owner's private Markdown scanner skipped unmatched one- and two-backtick openers, while the canonical Markdown code-span owner already treats those spans as protected through the end of the message. The scanner now locates the first genuine unescaped code delimiter, honors odd/even preceding backslashes, and protects real unfinished code through the end of the message. Simplifying the owner removes eight production lines overall.

User Impact

Messages such as Run \notify @Alice` remain literal unfinished code instead of unexpectedly pinging Alice. Escaped literal backticks do not suppress later legitimate mentions; odd/even backslash parity, balanced inline code, fenced code, ordinary intentional mentions, bot delivery, and persona webhooks keep their existing behavior.

Evidence

  • Four authentic owner and provider-boundary regressions failed before the original repair; four additional escaped-delimiter owner/transport regressions failed before the review follow-up.
  • node scripts/run-vitest.mjs extensions/discord/src/mentions.test.ts extensions/discord/src/send.sends-basic-channel-messages.test.ts extensions/discord/src/send.webhook.proxy.test.ts passed all 123 tests.
  • Actual production Discord bot REST and webhook HTTP payloads were independently exercised using local fake transports; neither emits a native user mention after the fix.
  • Focused type-aware lint, formatting, maximum-lines/assertion ratchets, odd/even backslash parity cases, and fresh independent complete-branch structured review passed.
  • Production delta: +11/-19 lines, net -8.

@clawsweeper

clawsweeper Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added channel: discord Channel integration: discord size: S maintainer Maintainer-authored PR labels Aug 25, 2026
@steipete
steipete marked this pull request as ready for review August 25, 2026 13:16
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 25, 2026
@clawsweeper

clawsweeper Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 25, 2026, 9:58 AM ET / 13:58 UTC.

ClawSweeper review

What this changes

The PR updates Discord known-mention rewriting so unfinished unescaped inline code protects the remaining text, while escaped backticks still allow later intended mentions to be converted.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

No blocking correctness finding: the prior escaped-backtick concern is addressed. Keep this maintainer-associated PR open until its exact-head checks complete.

Priority: P2
Reviewed head: 17d4baf3c3a501062822d0d5f3754f016d6f6fbd

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A narrow owner-boundary patch with focused direct and transport-boundary coverage; active exact-head checks remain the landing gate.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-associated PR is exempt from the external-contributor proof gate; its stated fake-transport evidence is supplemental rather than a live Discord claim.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-associated PR is exempt from the external-contributor proof gate; its stated fake-transport evidence is supplemental rather than a live Discord claim.
Evidence reviewed 6 items Current-main defect: Current main continues past an unmatched one- or two-backtick run, so its trailing text is sent to plain mention rewriting; this is the source-level path the PR repairs.
Updated owner behavior: The PR locates only unescaped delimiters and protects an unmatched short inline-code run through the end of the text.
Canonical Markdown contract: Markdown Core explicitly treats escaped backticks as non-delimiters, matching the repaired scanner rule without crossing the plugin boundary into core internals.
Findings None None.
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs extensions/discord/src/mentions.test.ts

Result: PASS (completed)

node scripts/run-vitest.mjs extensions/discord/src/mentions.test.ts
runner@runnervm76f27:/tmp/clawsweeper-live-proof-129338-FC4e7f/target$ node scripts/run-vitest.mjs extensions/discord/src/mentions.test.ts
node scripts/run-vitest.mjs extensions/discord/src/mentions.test.ts
[test] starting test/vitest/vitest.extension-discord.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-129338-FC4e7f/target

 ✓  extension-discord  extensions/discord/src/mentions.test.ts (19 tests) 58ms

 Test Files  1 passed (1)
      Tests  19 passed (19)
   Start at  13:59:31
   Duration  1.35s (transform 1.05s, setup 788ms, import 222ms, tests 58ms, environment 0ms)

[test] passed 1 Vitest shard in 5.87s
runner@runnervm76f27:/tmp/clawsweeper-live-proof-129338-FC4e7f/target$ node scripts/run-vitest.mjs extensions/discord/src/mentions.test.ts



































Assertions:

  • PASS expect_output: mentions.test.ts

How this fits together

Discord outbound text is normalized before bot REST or persona-webhook delivery. This rewrite step converts cached handles into native Discord mentions while preserving Markdown code as literal text.

flowchart LR
  A[Outbound message text] --> B[Discord mention rewriter]
  B --> C{Markdown code boundary}
  C -->|code text| D[Preserve literal handle]
  C -->|ordinary text| E[Convert cached handle]
  D --> F[Bot REST or webhook payload]
  E --> F
Loading

Before merge

  • Resolve merge risk (P1) - GitHub reports the branch as mergeable but behind main; land only after the exact-head build, lint, and extension-config checks finish green.
Agent review details

Security

None.

PR surface

Source -8, Tests +64. Total +56 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 1 11 19 -8
Tests 3 93 29 +64
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 104 48 +56

Review metrics

Metric Value Why it matters
Production versus test LOC production +11/-19 (net -8); tests +93/-29 (net +64) The repair simplifies production scanning while the added lines are focused regression and transport-boundary coverage.

Stored data model

Persistent data-model change detected: serialized state: extensions/discord/src/send.webhook.proxy.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Land the narrow Discord-owner repair after exact-head checks are green, preserving literal unfinished code without suppressing mentions after escaped backticks.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Land the narrow Discord-owner repair after exact-head checks are green, preserving literal unfinished code without suppressing mentions after escaped backticks.

Do we have a high-confidence way to reproduce the issue?

Yes, in source: current main skips an unmatched short backtick run and rewrites the remaining suffix; the focused owner and payload cases describe that path, though this read-only review did not execute them.

Is this the best way to solve the issue?

Yes. The repair stays in the Discord mention owner, and the canonical Markdown Core test independently supports its escaped-delimiter rule without importing core internals.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against b0088684da37.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-associated PR is exempt from the external-contributor proof gate; its stated fake-transport evidence is supplemental rather than a live Discord claim.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove merge-risk: 🚨 compatibility: Current PR review selected no merge-risk labels.
  • remove merge-risk: 🚨 message-delivery: Current PR review selected no merge-risk labels.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This is a bounded Discord outbound-message correctness repair with limited blast radius.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-associated PR is exempt from the external-contributor proof gate; its stated fake-transport evidence is supplemental rather than a live Discord claim.

Evidence

What I checked:

Likely related people:

  • steipete: Authored both commits in this focused mention-rewrite repair; available shallow history identifies this current source ownership but not an earlier introducer. (role: current Discord area contributor; confidence: medium; commits: 1b30f70d887a, 17d4baf3c3a5; files: extensions/discord/src/mentions.ts, extensions/discord/src/mentions.test.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Let the exact-head build, lint, and Discord extension-config checks finish green.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-25T13:21:57.311Z sha 1b30f70 :: needs changes before merge. :: [P2] Skip escaped backticks before opening a protected segment

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 25, 2026
@steipete
steipete merged commit 712a97d into main Aug 25, 2026
120 checks passed
@steipete
steipete deleted the codex/qa-discord-inline-code-mentions-20260825 branch August 25, 2026 14:11
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 26, 2026
…nclaw#129338)

* fix(discord): protect mentions inside unfinished inline code

* fix(discord): respect escaped inline-code delimiters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: discord Channel integration: discord maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant