Repository navigation
Conversation
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Close this PR as superseded: the useful Feishu mention-prefix fix is now owned by an open, mergeable, maintainer-labeled replacement PR with the same longer-key-first strategy and focused coverage. Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Canonical path: Land or close the maintainer-owned #96311 as the canonical fix, optionally carrying over this PR's extra adjacent-longer-key test if desired. So I’m closing this here and keeping the remaining discussion on #96311. Review detailsBest possible solution: Land or close the maintainer-owned #96311 as the canonical fix, optionally carrying over this PR's extra adjacent-longer-key test if desired. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: current main passes parsed Feishu text and message.mentions into normalizeMentions, whose current replacement loop can rewrite @_user_1 inside @_user_10 before the longer key is processed. I did not run tests because this review is read-only. Is this the best way to solve the issue? Yes for the algorithm, but no for this duplicate branch as the landing path: descending key length fixes the collision without delimiter assumptions, and the maintainer-owned replacement PR is the safer canonical route. Security review: Security review cleared: The diff only changes Feishu TypeScript mention normalization and colocated tests; no dependency, workflow, lockfile, secret, permission, or downloaded-code surface is touched. AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against 74214000bf48. |
…ions Feishu assigns sequential, non-zero-padded mention keys (@_user_1, @_user_2, ... @_user_10, @_user_11). normalizeMentions replaced each key with a global regex, so once a message mentions 10+ users the @_user_1 replacement also matched the @_user_1 prefix inside @_user_10/@_user_11/..., corrupting the longer-keyed users. Replace longer keys first so a shorter key can never match inside a longer one (the longer key is already substituted by the time the shorter key's turn comes), which also correctly handles a key immediately followed by text. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
44447e0 to
484a007
Compare
|
@clawsweeper re-review — addressed the rank-up: replaced the lookahead with a longer-key-first algorithm (sort mention keys by length descending, then global replace) so a shorter key can never match inside a longer one, and added a test covering a key immediately followed by ASCII text ( |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
Closing to stay under the repo's active-PR limit and keep my queue focused on changes I can fully prove headlessly. This channel fix needs live-channel proof I can't generate in my current environment; the code change itself stands and I'll resubmit with live proof when I can run the channel. |
Summary
Feishu assigns sequential, non-zero-padded mention keys —
@_user_1, …@_user_10,@_user_11.normalizeMentions(extensions/feishu/src/bot-content.ts) replaced each key withnew RegExp(escaped(mention.key), "g")— a global match with no right-side boundary. So when a message mentions 10+ users, the regex for@_user_1also matches the@_user_1prefix inside@_user_10/@_user_11/…, substituting the shorter mention's replacement into the longer key (e.g.@_user_10becomes<at user_id="ou_alice">Alice</at>0). The longer key's own regex then no longer matches, so users 10–19 are silently lost/mis-attributed.normalizeMentionsruns on every inbound Feishu text message (parseFeishuMessageEvent); the returned text is what the agent/model sees.Changes
bot-content.ts— anchor the per-key match with a(?![\w])negative lookahead so a shorter key cannot match inside a longer one.bot-content.test.ts— new colocated prefix-collision test.Real behavior proof
Behavior addressed: a Feishu message mentioning both
@_user_1and@_user_1Xlost/mis-attributed users 10–19; after the fix each keeps its own<at>tag.Real environment tested: Node 22.22.1, macOS, no network/model. Vitest exercises the real exported
normalizeMentions. BEFORE isorigin/main'sbot-content.ts(swapped viagit show).Exact steps or command run after this patch:
Evidence after fix:
Observed result after fix: each mention resolves to its own user; the new test fails on
origin/main, passes after.What was not tested: a live Feishu group round-trip (the test drives the real
normalizeMentionsthatparseFeishuMessageEventcalls). Existingbot.stripBotMention.test.tsstays green.Additional checks
node scripts/run-vitest.mjs extensions/feishu/src/bot-content.test.tspasses; fail-before verified by swapping inorigin/main's file.bot.stripBotMention.test.tsstays green. Extensionoxlintclean.