← Back to PRs

#13829: fix(googlechat): detect bot @mentions via user.type when botUser not configured

by mcaxtr open 2026-02-11 02:44 View on GitHub →
channel: googlechat size: S trusted-contributor experienced-contributor
## Summary Fixes #12323 Google Chat webhooks send numeric user IDs (e.g. `users/112986094383820258709`) instead of the `users/app` alias for bot @mentions. Without `botUser` explicitly configured, `extractMentionInfo()` failed to recognize these mentions, causing the bot to silently ignore messages where it was @mentioned. **Root cause:** `extractMentionInfo()` only checked `botTargets` (containing `users/app` and optional `botUser`) and the `normalizeUserId() === "app"` path. Numeric user IDs don't match either check. **Fix:** When `botUser` is not configured and existing checks fail, fall back to checking `user.type === "BOT"` from the annotation metadata. For multi-bot Space safety, this fallback only triggers when exactly one distinct BOT-type user exists in the annotations — if multiple different bots are mentioned, the ambiguity requires explicit `botUser` configuration. ## Changes - `extensions/googlechat/src/monitor.ts`: Added BOT user type fallback in `extractMentionInfo()` with distinct-user multi-bot safety guard - `extensions/googlechat/src/monitor.test.ts`: Added 10 new tests covering all mention detection paths ## Test plan - [x] `users/app` alias detection still works - [x] Explicit `botUser` config detection still works - [x] BOT user type fallback detects mentions when `botUser` not configured - [x] Multi-bot safety: rejects when multiple distinct BOT users exist - [x] Explicit `botUser` overrides multi-bot guard - [x] HUMAN-type mentions don't trigger bot - [x] Empty and non-USER_MENTION annotations handled correctly - [x] Same bot mentioned twice (duplicate annotations) still detected - [x] BOT mention alongside human mentions still detected - [x] All 14 tests fail before fix, pass after fix <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR fixes Google Chat bot @mention detection when webhooks send numeric user IDs (e.g. `users/112...`) instead of the `users/app` alias and `botUser` is not configured. It does this by exporting and enhancing `extractMentionInfo()` in `extensions/googlechat/src/monitor.ts` to fall back to `annotation.userMention.user.type === "BOT"` when the existing `users/app` / `botUser` matching fails. To avoid incorrect triggering in multi-bot spaces, the fallback only applies when there is exactly one distinct BOT user in the message annotations. The accompanying tests in `extensions/googlechat/src/monitor.test.ts` cover alias matching, explicit `botUser`, BOT-type fallback, multi-bot guard behavior, and ignoring non-mention annotations. <h3>Confidence Score: 5/5</h3> - This PR is safe to merge with minimal risk. - Changes are localized to mention detection logic and are guarded to avoid multi-bot ambiguity; added unit tests cover the new fallback and existing mention paths. No breaking internal usage was found beyond exporting a helper that is only used within the module and tests. - No files require special attention <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs