Skip to content

(googlechat) fix: space messaging, introduce deduplication, and update reply-to defaults - #42330

Closed
lamdt1 wants to merge 5 commits into
openclaw:mainfrom
lamdt1:fix-googlechat-space
Closed

lamdt1 wants to merge 5 commits into
openclaw:mainfrom
lamdt1:fix-googlechat-space

Conversation

@lamdt1

@lamdt1 lamdt1 commented Mar 10, 2026

Copy link
Copy Markdown

Summary

Describe the problem and fix in 2–5 bullets:

  • Problem: Google Chat messages in Spaces were not handling threads/reply-to correctly, and duplicate events from Google's webhook often caused redundant bot responses.
  • Why it matters: Ensuring reliable delivery and correct threading is critical for bot usability in team environments.
  • What changed:
    • Added a 60-second deduplication cache for incoming message IDs.
    • Updated default replyToMode for Google Chat from off to all in src/channels/dock.ts.
    • Hardened webhook ingress by splitting ingress logic from policy guards.
    • Added support for ADDED_TO_SPACE events.
  • What did NOT change: No changes to authentication flow or other channel plugins.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

  • Related # (Please link the original issue if applicable)

User-visible / Behavior Changes

  • Default Setting: replyToMode for Google Chat now defaults to all instead of off.
  • Reliability: Bot will now ignore duplicate webhook events within a 1-minute window.

Security Impact (required)

  • New permissions/capabilities? (No)
  • Secrets/tokens handling changed? (No)
  • New/changed network calls? (No)
  • Command/tool execution surface changed? (No)
  • Data access scope changed? (No)

Repro + Verification

Environment

  • OS: macOS / Linux
  • Runtime/container: Node 22+
  • Integration/channel (if any): Google Chat extension

Steps

  1. Add the bot to a Google Chat Space.
  2. Send a message to the bot.
  3. Observe if the bot replies in the same thread.
  4. Simulate duplicate webhook triggers to verify deduplication.

Expected

  • Bot replies correctly in-thread.
  • Each unique message triggers exactly one bot response.

Actual

  • Bot replies in-thread and ignores duplicate events.

Evidence

  • Trace/log snippets (Verified recentlyProcessedMessages cache behavior locally).

Human Verification (required)

  • Verified scenarios: Tagging bot in Spaces, Direct Messages, and handling of duplicate webhook payloads.
  • Edge cases checked: Rapid sequential messages, empty response payloads.
  • What you did not verify: High-volume traffic (exceeding 1000 msgs/min).

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible? (Yes)
  • Config/env changes? (None)
  • Migration needed? (No)

Failure Recovery (if this breaks)

  • How to disable/revert this change quickly: Revert the changes in src/channels/dock.ts and extensions/googlechat/src/.
  • Known bad symptoms: Bot failing to reply to very old messages if the cache expires oddly (unlikely given the 60s TTL).

Risks and Mitigations

  • Risk: The 60s deduplication cache uses memory (Map).
    • Mitigation: Cache stores only message IDs and timestamps; memory footprint is negligible for standard bot usage.

@greptile-apps

greptile-apps Bot commented Mar 10, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes Google Chat Space messaging by correcting thread/reply-to handling, adding a 60-second in-memory deduplication cache to prevent duplicate bot responses, updating the default replyToMode from "off" to "all", and hardening the webhook ingress pipeline. It also adds ADDED_TO_SPACE event support and refactors several plugin-SDK helper abstractions to inline implementations.

Key concerns found during review:

  • Security — missing JWT algorithm validation (auth.ts): manualVerifyGoogleJwt does not explicitly validate that header.alg is "RS256" before proceeding to signature verification. The ternary on line 255 is dead code (header.alg === "RS256" ? "sha256" : "sha256") — both branches produce the same value, masking the absence of an actual algorithm allow-list check.
  • Debug logs left in production hot paths: Multiple console.log / console.warn statements were added across monitor.ts, monitor-access.ts, and auth.ts that unconditionally log user IDs, email addresses, space identifiers, and message IDs on every inbound event. These should be removed or replaced with the existing logVerbose helper.
  • Potential regression in sendMedia (channel.ts): Local media loading via loadWebMedia was removed; fetchRemoteMedia is now called unconditionally for all mediaUrl values. Any caller passing a non-http(s):// URL will receive an error at runtime.
  • Redundant dynamic crypto import (auth.ts line 210): crypto is already statically imported at the top of the file; the await import("node:crypto") inside manualVerifyGoogleJwt creates a redundant binding that shadows it.

Confidence Score: 2/5

  • Not safe to merge as-is due to a security gap in JWT algorithm validation and production-impacting debug log exposure.
  • The missing algorithm validation in the manual JWT verifier is a meaningful security gap — Google's JWKS could theoretically serve keys for multiple algorithms and the code does not enforce RS256-only verification. The proliferation of unconditional console.log statements on every inbound message is a privacy concern in production deployments and should not land without removal or gating. The sendMedia regression may silently break existing users of local media. These issues collectively lower confidence below the "safe with minor notes" threshold.
  • extensions/googlechat/src/auth.ts (JWT algorithm validation gap, redundant crypto import), extensions/googlechat/src/channel.ts (sendMedia local media regression), extensions/googlechat/src/monitor.ts and monitor-access.ts (debug console.log in hot paths)

Last reviewed commit: dc91f50

Comment on lines +254 to +258
const isValid = crypto.verify(
header.alg === "RS256" ? "sha256" : "sha256",
Buffer.from(signedData),
publicKey,
signature,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dead ternary and missing algorithm validation in JWT verification

Both branches of the ternary on line 255 evaluate to "sha256", making it dead code that misleadingly suggests algorithm-awareness. More critically, header.alg is never validated before this point — a JWT with alg: "RS512" or alg: "ES256" would proceed through the signature check using sha256 (incorrect algorithm) without being explicitly rejected. For alg: "none", crypto.verify will likely return false and be caught, but the intent to strictly allow only RS256 is not enforced.

The algorithm should be explicitly validated before reaching the signature verification step:

Suggested change
const isValid = crypto.verify(
header.alg === "RS256" ? "sha256" : "sha256",
Buffer.from(signedData),
publicKey,
signature,
if (header.alg !== "RS256") {
return { ok: false, reason: `unsupported algorithm: ${header.alg}` };
}
const isValid = crypto.verify(
"sha256",
Buffer.from(signedData),
publicKey,
signature,
);
Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/googlechat/src/auth.ts
Line: 254-258

Comment:
**Dead ternary and missing algorithm validation in JWT verification**

Both branches of the ternary on line 255 evaluate to `"sha256"`, making it dead code that misleadingly suggests algorithm-awareness. More critically, `header.alg` is never validated before this point — a JWT with `alg: "RS512"` or `alg: "ES256"` would proceed through the signature check using `sha256` (incorrect algorithm) without being explicitly rejected. For `alg: "none"`, `crypto.verify` will likely return `false` and be caught, but the intent to strictly allow only `RS256` is not enforced.

The algorithm should be explicitly validated before reaching the signature verification step:

```suggestion
  if (header.alg !== "RS256") {
    return { ok: false, reason: `unsupported algorithm: ${header.alg}` };
  }

  const isValid = crypto.verify(
    "sha256",
    Buffer.from(signedData),
    publicKey,
    signature,
  );
```

How can I resolve this? If you propose a fix, please make it concise.

Comment thread extensions/googlechat/src/auth.ts Outdated
payload?: { iss?: string; aud?: string; email?: string; email_verified?: boolean; exp?: number; sub?: string };
reason?: string;
}> {
const crypto = await import("node:crypto");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant dynamic import shadows static module-level import

crypto is already statically imported at line 2 (import crypto from "node:crypto"). The dynamic await import("node:crypto") here creates a new local binding that shadows the module-level one, which is confusing and adds unnecessary overhead on every call.

Suggested change
const crypto = await import("node:crypto");
// crypto is already available from the top-level static import

Remove the dynamic import and use the top-level crypto binding directly throughout manualVerifyGoogleJwt.

Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/googlechat/src/auth.ts
Line: 210

Comment:
**Redundant dynamic import shadows static module-level import**

`crypto` is already statically imported at line 2 (`import crypto from "node:crypto"`). The dynamic `await import("node:crypto")` here creates a new local binding that shadows the module-level one, which is confusing and adds unnecessary overhead on every call.

```suggestion
  // crypto is already available from the top-level static import
```

Remove the dynamic import and use the top-level `crypto` binding directly throughout `manualVerifyGoogleJwt`.

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines +96 to +98
if (hasAnyMention) {
console.log(`[googlechat/access] extractMentionInfo: botTargets=${Array.from(botTargets).join(",")}, mentions=${JSON.stringify(mentionAnnotations.map(m => m.userMention?.user))}`);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug console.log statements left in production code

Several debug console.log / console.warn statements were left in production paths and log sensitive data including user objects, email addresses, space IDs, and message IDs. In a deployed environment these will appear in every applicable log stream and may violate user privacy expectations.

Affected locations across this PR (beyond this line):

  • extensions/googlechat/src/monitor-access.ts:97 — logs all mention user objects
  • extensions/googlechat/src/monitor-access.ts:112 (BOT type match log)
  • extensions/googlechat/src/monitor-access.ts:291 — group message policy decision log
  • extensions/googlechat/src/monitor-access.ts:318 — sender policy drop log
  • extensions/googlechat/src/monitor.ts:101 — ADDED_TO_SPACE log
  • extensions/googlechat/src/monitor.ts:181 — logs duplicate message ID on console.warn
  • extensions/googlechat/src/monitor.ts:189 — logs space ID, type, and message ID on every message
  • extensions/googlechat/src/monitor.ts:~487 — delivery chunk log
  • extensions/googlechat/src/auth.ts:282–296 — logs audience, token verification outcome, and email

These should either be removed or replaced with the existing logVerbose helper which is gated behind a flag and does not use console.log.

Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/googlechat/src/monitor-access.ts
Line: 96-98

Comment:
**Debug console.log statements left in production code**

Several debug `console.log` / `console.warn` statements were left in production paths and log sensitive data including user objects, email addresses, space IDs, and message IDs. In a deployed environment these will appear in every applicable log stream and may violate user privacy expectations.

Affected locations across this PR (beyond this line):
- `extensions/googlechat/src/monitor-access.ts:97` — logs all mention user objects
- `extensions/googlechat/src/monitor-access.ts:112` (BOT type match log)
- `extensions/googlechat/src/monitor-access.ts:291` — group message policy decision log
- `extensions/googlechat/src/monitor-access.ts:318` — sender policy drop log
- `extensions/googlechat/src/monitor.ts:101` — ADDED_TO_SPACE log
- `extensions/googlechat/src/monitor.ts:181` — logs duplicate message ID on `console.warn`
- `extensions/googlechat/src/monitor.ts:189` — logs space ID, type, and message ID on every message
- `extensions/googlechat/src/monitor.ts:~487` — delivery chunk log
- `extensions/googlechat/src/auth.ts:282–296` — logs audience, token verification outcome, and email

These should either be removed or replaced with the existing `logVerbose` helper which is gated behind a flag and does not use `console.log`.

How can I resolve this? If you propose a fix, please make it concise.

Comment thread extensions/googlechat/src/channel.ts Outdated
Comment on lines +446 to +449
const loaded = await runtime.channel.media.fetchRemoteMedia({
url: mediaUrl,
maxBytes: maxBytes ?? (account.config.mediaMaxMb ?? 20) * 1024 * 1024,
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Local media loading support silently removed from sendMedia

The previous implementation distinguished between remote URLs and local paths:

const loaded = /^https?:\/\//i.test(mediaUrl)
  ? await runtime.channel.media.fetchRemoteMedia({ url: mediaUrl, maxBytes: effectiveMaxBytes })
  : await runtime.media.loadWebMedia(mediaUrl, { maxBytes: effectiveMaxBytes, localRoots: mediaLocalRoots?.length ? mediaLocalRoots : undefined });

The new code unconditionally calls fetchRemoteMedia, meaning any mediaUrl that isn't an http(s):// URL (e.g. a local file path) will be passed to fetchRemoteMedia, which will either throw or return an error. If any callers pass local media paths to this adapter, this is a silent regression. Additionally, mediaLocalRoots was removed from the function signature, discarding that capability entirely.

If local media is no longer a supported use-case for Google Chat, this should be explicitly documented. If it is still supported, the URL-check branch should be restored.

Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/googlechat/src/channel.ts
Line: 446-449

Comment:
**Local media loading support silently removed from `sendMedia`**

The previous implementation distinguished between remote URLs and local paths:
```ts
const loaded = /^https?:\/\//i.test(mediaUrl)
  ? await runtime.channel.media.fetchRemoteMedia({ url: mediaUrl, maxBytes: effectiveMaxBytes })
  : await runtime.media.loadWebMedia(mediaUrl, { maxBytes: effectiveMaxBytes, localRoots: mediaLocalRoots?.length ? mediaLocalRoots : undefined });
```

The new code unconditionally calls `fetchRemoteMedia`, meaning any `mediaUrl` that isn't an `http(s)://` URL (e.g. a local file path) will be passed to `fetchRemoteMedia`, which will either throw or return an error. If any callers pass local media paths to this adapter, this is a silent regression. Additionally, `mediaLocalRoots` was removed from the function signature, discarding that capability entirely.

If local media is no longer a supported use-case for Google Chat, this should be explicitly documented. If it is still supported, the URL-check branch should be restored.

How can I resolve this? If you propose a fix, please make it concise.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dc91f505b8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread extensions/googlechat/src/channel.ts Outdated
Comment on lines +446 to +448
const loaded = await runtime.channel.media.fetchRemoteMedia({
url: mediaUrl,
maxBytes: maxBytes ?? (account.config.mediaMaxMb ?? 20) * 1024 * 1024,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Restore local media loading for Google Chat sendMedia

This path now always uses fetchRemoteMedia, so local file payloads (for example tool outputs under agent workspace roots) are treated as remote URLs and fail instead of being loaded via mediaLocalRoots. The outbound pipeline still forwards local roots to channel adapters, and Google Chat already had explicit local-media coverage, so this change regresses attachment delivery for non-HTTP media paths.

Useful? React with 👍 / 👎.

Comment on lines +113 to +115
if (user?.type === "BOT") {
console.log(`[googlechat/access] Matched mention by type===BOT: ${userName}`);
return true;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Match mentions against bot identity, not any BOT user

Treating any mention with user.type === "BOT" as a match makes mention-gating over-permissive: in spaces with multiple bots, mentioning a different bot will still mark OpenClaw as mentioned and allow processing even when requireMention is enabled. This can trigger unsolicited replies in group spaces and should be constrained to known bot identifiers (users/app/configured bot user).

Useful? React with 👍 / 👎.

Comment thread extensions/googlechat/src/monitor.ts Outdated
Comment on lines +180 to +184
if (recentlyProcessedMessages.has(msgId)) {
console.warn(`[googlechat/dedup] Skipping duplicate message: ${msgId} (already processed within ${DEDUP_TTL_MS}ms)`);
return;
}
recentlyProcessedMessages.set(msgId, Date.now());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Add dedup marker only after successful message processing

The message ID is marked as processed before access checks and downstream handling complete. If anything later throws (for example media download or reply dispatch), retries/duplicate webhook deliveries for the same message.name are skipped for the full TTL, which can silently drop user messages instead of allowing a retry path.

Useful? React with 👍 / 👎.

Comment thread extensions/googlechat/src/auth.ts Outdated
Comment on lines +105 to +106
const cacheKey = account.accountId;
const cached = accessTokenCache.get(cacheKey);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Key access-token cache by credential fingerprint

The manual token cache uses only accountId, so rotating service-account credentials on the same account keeps reusing the previous token until expiry. After config reloads or key revocation, this can cause prolonged auth failures (or continued use of stale credentials) because the cache is not invalidated when credential material changes.

Useful? React with 👍 / 👎.

@openclaw-barnacle openclaw-barnacle Bot added channel: googlechat Channel integration: googlechat size: L labels Mar 10, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8128e100e9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +270 to +272
const key = jwks.find((k) => k.kid === header.kid);
if (!key) {
return { ok: false, reason: `no matching key found for kid=${header.kid}` };

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Refresh JWKS on kid cache miss before rejecting token

When manualVerifyGoogleJwt cannot find the token's kid in the cached JWKS set, it immediately rejects the request instead of forcing a JWKS refresh. Because fetchGoogleJwks serves cache entries for up to 10 minutes, normal Google key rotation can cause valid app-url webhook tokens to fail verification for the full cache window, producing intermittent auth outages until the TTL expires.

Useful? React with 👍 / 👎.

}

if (!event.space || typeof event.space !== "object" || Array.isArray(event.space)) {
console.error(`[googlechat/webhook] invalid payload (no space object): type=${eventType} payload=${JSON.stringify(raw).slice(0, 500)}`);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Stop logging raw Google Chat webhook payloads

The new parse-error logging dumps raw webhook JSON into logs, which can include authorizationEventObject.systemIdToken and user message content in Add-on requests. In malformed-request scenarios this leaks bearer material and sensitive payload data to log sinks, so these branches should log only sanitized metadata instead of body content.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c0f466ca79

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +176 to +179
const msgId = message.name ?? "";
if (msgId) {
pruneDedup();
if (recentlyProcessedMessages.has(msgId)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Namespace dedup keys by account before skipping messages

The dedup cache currently keys only on message.name, but this map is module-global and shared across all configured Google Chat accounts. In multi-account deployments, the same space message ID can be observed by different bot accounts, so one account processing it first will cause the other account to drop it as a “duplicate” for 60 seconds. Include account.accountId (or another account-unique discriminator) in the dedup key to avoid cross-account message loss.

Useful? React with 👍 / 👎.

Comment on lines +379 to +381
// Mark as processed only after successful dispatch
if (msgId) {
recentlyProcessedMessages.set(msgId, Date.now());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Only mark dedup after a confirmed outbound send

The message is marked processed immediately after dispatchReplyWithBufferedBlockDispatcher returns, but deliverGoogleChatReply swallows send/upload failures and logs them instead of throwing, so dispatch can resolve even when no reply was actually delivered. In that failure path, retries of the same webhook event are suppressed by dedup for the full TTL, which drops recoverable messages; a success signal from delivery (or propagating delivery errors) is needed before inserting into the dedup map. Fresh evidence: deliverGoogleChatReply catches and suppresses send failures in its media/text loops, so dispatch completion is not equivalent to successful delivery.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7762373cb9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +100 to +101
if (eventType === "ADDED_TO_SPACE" && !event.message) {
return;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Handle ADDED_TO_SPACE events without message payload

parseGoogleChatInboundPayload now maps add-on requests without chat.message to type: "ADDED_TO_SPACE", but processGoogleChatEvent immediately returns when event.message is absent, so those events never reach the pipeline. In practice, ADDED_TO_SPACE callbacks commonly omit a message object, which means the new added-to-space path is effectively dropped and any onboarding/welcome handling tied to that event cannot run.

Useful? React with 👍 / 👎.

@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Apr 27, 2026
@clawsweeper

clawsweeper Bot commented Apr 27, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Close this PR as superseded: the central Google Chat Space/DM classification problem is now tracked by the narrower, open, mergeable replacement PR, while this older branch is conflicting and still carries auth, logging, delivery, and compatibility regressions that should not be salvaged as one broad patch.

Canonical path: Close this broad conflicting branch and keep the remaining Space/DM classifier work on #58993; any dedupe, reply-default, Add-on, or ADDED_TO_SPACE behavior should return as separate, current-main PRs with explicit tests and proof.

So I’m closing this here and keeping the remaining discussion on #58993.

Review details

Best possible solution:

Close this broad conflicting branch and keep the remaining Space/DM classifier work on #58993; any dedupe, reply-default, Add-on, or ADDED_TO_SPACE behavior should return as separate, current-main PRs with explicit tests and proof.

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

Yes for the PR blockers at source level: the live PR head removes Add-on principal binding, logs raw webhook payloads, keys dedupe only by message.name, and changes reply defaults. The original Space/DM classifier gap is also source-reproducible on current main and is now covered by the narrower replacement PR.

Is this the best way to solve the issue?

No. The maintainable solution is the focused current-main classifier PR plus separate, reviewed follow-ups for dedupe, Add-on event support, and reply-default policy if maintainers still want those changes.

Security review:

Security review needs attention: The diff changes Google Chat auth and webhook logging and introduces concrete security-sensitive regressions.

  • [high] Add-on token principal binding is removed — extensions/googlechat/src/monitor-webhook.ts:156
    Current main checks the configured appPrincipal for app-url Add-on tokens, but the PR verifier/caller no longer carries expectedAddOnPrincipal, weakening the webhook auth boundary for shared or reused audiences.
    Confidence: 0.96
  • [medium] Raw webhook payloads can be written to logs — extensions/googlechat/src/monitor-webhook.ts:91
    The PR logs JSON.stringify(raw) for malformed payloads, which can expose Add-on bearer tokens and private Google Chat message content to log sinks.
    Confidence: 0.91

What I checked:

  • Live PR state: Live GitHub data shows this PR is open but CONFLICTING at head 7762373, with six changed files across Google Chat auth, webhook, monitor, channel, and the old core dock file. (7762373cb9c5)
  • Canonical replacement: The linked replacement PR is open and MERGEABLE, touches only extensions/googlechat/src/monitor.ts and extensions/googlechat/src/types.ts, and targets the modern Google Chat spaceType/singleUserBotDm classifier problem that matches the central Space messaging report. (3b20c6a86c57)
  • Current-main classifier gap: Current main still derives Google Chat group/direct classification only from legacy space.type, which explains why the focused replacement PR is the right remaining path for the Space/DM routing issue. (extensions/googlechat/src/monitor.ts:183, ee61f79b901d)
  • Replacement PR patch scope: The replacement PR adds the modern spaceType and singleUserBotDm fields and classifies as a group only when legacy type, modern type, and singleUserBotDm all fail to indicate a direct message. (extensions/googlechat/src/monitor.ts:158, 3b20c6a86c57)
  • Current-main auth boundary: Current main verifies app-url Add-on tokens against the configured appPrincipal by passing expectedAddOnPrincipal into verifyGoogleChatRequest. (extensions/googlechat/src/monitor-webhook.ts:122, ee61f79b901d)
  • PR removes auth binding: The PR head's webhook auth call passes bearer, audienceType, and audience but no appPrincipal/expectedAddOnPrincipal, and its verifier signature has no binding parameter, so the current-main Add-on principal check is lost. (extensions/googlechat/src/monitor-webhook.ts:156, 7762373cb9c5)

Likely related people:

  • steipete: Peter Steinberger authored the current Google Chat webhook/access-policy split and much of the recent channel security and reply-routing history touched by this PR. (role: recent area contributor; confidence: high; commits: 1c9deeda97ce, 64de4b6d6ae8, 85b7bc7edf; files: extensions/googlechat/src/monitor-access.ts, extensions/googlechat/src/monitor-webhook.ts, extensions/googlechat/src/channel.adapters.ts)
  • vincentkoc: Vincent Koc recently tightened inbound callback and allowlist checks and internalized Google Chat SDK imports in the same auth/webhook surface. (role: recent auth/webhook contributor; confidence: high; commits: a47722de7e3c, 5e78c8bc95, 2b67a3f76e90; files: extensions/googlechat/src/auth.ts, extensions/googlechat/src/monitor-webhook.ts, extensions/googlechat/src/channel.ts)
  • iHildy: iHildy introduced the beta Google Chat channel and the Workspace Add-on event-format support that this PR modifies. (role: introduced feature area; confidence: medium; commits: b76cd6695d11, 5991bed32e; files: extensions/googlechat/src/monitor.ts, extensions/googlechat/src/auth.ts, extensions/googlechat/src/types.ts)
  • gumadeiras: Gustavo Madeira Santana carried Google Chat plugin-SDK migration work that overlaps this PR's attempted helper refactor. (role: adjacent plugin-boundary contributor; confidence: medium; commits: 39a55844bc5d, a1e21bc02d; files: extensions/googlechat/src/channel.ts, extensions/googlechat/src/monitor.ts)

Codex review notes: model gpt-5.5, reasoning high; reviewed against ee61f79b901d.

@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label Apr 28, 2026
@clawsweeper clawsweeper Bot added the P1 High-priority user-facing bug, regression, or broken workflow. label May 16, 2026
@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. label May 16, 2026
@clawsweeper clawsweeper Bot added impact:security Security boundary, credential, authz, sandbox, or sensitive-data risk. impact:message-loss Channel message delivery can be lost, duplicated, or misrouted. impact:auth-provider Auth, provider routing, model choice, or SecretRef resolution may break. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. 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. and removed impact:security Security boundary, credential, authz, sandbox, or sensitive-data risk. impact:message-loss Channel message delivery can be lost, duplicated, or misrouted. impact:auth-provider Auth, provider routing, model choice, or SecretRef resolution may break. labels May 17, 2026
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. label May 18, 2026
@clawsweeper

clawsweeper Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper PR egg

🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat.

Where did the egg go?
  • The egg game starts only after the PR passes the real-behavior proof check.
  • Before that, no creature or rarity is rolled. The treat waits for real proof.
  • This is still just collectible flavor: proof affects review readiness, not creature quality.

@clawsweeper

clawsweeper Bot commented May 23, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper applied the proposed close for this PR.

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

Labels

channel: googlechat Channel integration: googlechat merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. 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. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: L status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant