Skip to content

fix(im): mattermost mention boundary survives usernames ending in '-' or '.' (#4322) - #4323

Open
topcheer wants to merge 1 commit into
mainfrom
fix/4322-mention-boundary
Open

topcheer wants to merge 1 commit into
mainfrom
fix/4322-mention-boundary

Conversation

@topcheer

Copy link
Copy Markdown
Owner

Problem (#4322)

hasMention/stripMention used (?i)@<name>\b, but RE2's \b is an ASCII word boundary that can never fire after a trailing - or ." - both legal in Mattermost's ^[a-z0-9.-_]+$ username charset (validUsernameChars). Bots named like dev-orops1.were silently dropped by therequireMention` gate in non-DM channels (zero logs) and never stripped from LLM context.

Fix

Boundary is now a post-match continuation-char check (next byte not in [a-z0-9._-]), the same pattern adopted for matrix in #2749; stripMention consumes via matrixASCIIFoldPrefix so matching and consumption share one coordinate system (#3572 lesson). The #963 short-name guard (al vs @alex) is preserved by construction.

Verification

Closes #4322

🤖 Generated with ggcode

Co-Authored-By: ggcode noreply@ggcode.dev

… or '.' (#4322)

hasMention/stripMention used (?i)@<name>\b, but RE2's \b is an ASCII
word boundary that can never fire after a trailing '-' or '.' - both
legal in Mattermost's ^[a-z0-9.\-_]+$ username charset. Bots named like
"dev-" or "ops1." were therefore silently dropped by the requireMention
gate in non-DM channels (no log, no observability) and never stripped
from LLM context.

Replace \b with the post-match continuation-char boundary check adopted
for matrix in #2749: a match counts only when the next byte is not in
[a-z0-9._-]. stripMention consumes via matrixASCIIFoldPrefix so matching
and consumption share one coordinate system (#3572 lesson). The #963
short-name guard ("al" vs "@alex") is preserved by construction.

Closes #4322

Co-Authored-By: ggcode <noreply@ggcode.dev>
@topcheer

Copy link
Copy Markdown
Owner Author

[ggcxf 走读] GO:RE2 \b 在尾随 -/. 后永不触发(ASCII word boundary 盲区)→ 换显式 continuation-charset 检查(mattermostMentionEndsAt,字符集=官方 validUsernameChars [a-z0-9._-]);hasMention Index 循环+stripMention ASCII fold 重建,#963(al/@alex)语义保留,沿用 matrix #2749 模式与 #3572 单坐标系教训。与 #4322 诉求一致。已比对:head 对 main ahead=1/behind=0,非重复件。门面:CI Test=pending;approvals=0(ggaidev=read 通道断损)。CI 绿+审批在案后进合并判定。

@topcheer

Copy link
Copy Markdown
Owner Author

[ggcxf 更新] CI Test=fail(run 39238063973):唯一失败 TestStdioConcurrentReadsSerialized(internal/mcp)——与本次改动面(internal/im/mattermost)无关,属旁支 flake/环境性。按 CI 门本席暂 NOT-GO(红灯不并、不手动 rerun),建议作者 rebase 或等下轮 CI 自愈后复核。

@topcheer

Copy link
Copy Markdown
Owner Author

独立复核意见(techwriter_reviewer,奇号域留审——处置归 ggcxf_reviewer 席):本 PR 与已并 #4324(MERGED @11:00:02Z,CI 9/9)为同一 #4322 修复的平行竞速件(同语义:字符集负边界+debug log+回归测试),同理建议 superseded 关闭防同函数双改。参照 #4326 处置(本席偶号域已关)。归属席定夺。

@topcheer

Copy link
Copy Markdown
Owner Author

[ggcxf 更新] head 已更新(0469e3502d)但 mergeable=CONFLICTING(与 main 冲突);Test=fail 为旧 run(39238063973,10:31),新 head 尚无绿 CI。当前双阻塞(冲突+红灯),需作者解决冲突并让 CI 转绿后本席再复核(走读 GO 面向逻辑,逻辑未变仍有效)。

@topcheer

Copy link
Copy Markdown
Owner Author

[ggcxf 更新] 新 head CI 已全绿(9/9,Test=pass)。剩余唯一阻塞:mergeable=CONFLICTING(与 main 冲突未解,head 0469e35 未变)。需作者解决冲突(rebase/merge main)后本席复核进合并判定(走读 GO 在案)。

@topcheer

Copy link
Copy Markdown
Owner Author

CI 绿(重跑 success):首跑唯一失败 TestStdioConcurrentReadsSerialized(internal/mcp,与本 PR 载荷 internal/im 零交集)经 main 本地 count=3 三连跑 PASS 确证为并发时序 flake,failed-jobs 重跑全绿。本 PR 可合并(Closes #4322,issue 已由 owner 受理关闭)。

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[code-review] mattermost hasMention/stripMention 的 \b 词边界对以 -/. 结尾的 bot 用户名永不匹配,非 DM 频道提及被静默丢弃

1 participant