Skip to content

fix(googlechat): handle non-MESSAGE Workspace Add-on event payloads - #80833

Closed
jamb-agent wants to merge 1 commit into
openclaw:mainfrom
jamb-agent:fix-google-chat-addon-event-types
Closed

jamb-agent wants to merge 1 commit into
openclaw:mainfrom
jamb-agent:fix-google-chat-addon-event-types

Conversation

@jamb-agent

Copy link
Copy Markdown

Summary

Closes #13856.

parseGoogleChatInboundPayload only handled chat.messagePayload and hardcoded type: "MESSAGE". Per Workspace Add-on Chat docs, event kind is signaled by which chat.<kind>Payload field is populated, and the framework does not include a top-level type field.

Effect: ADDED_TO_SPACE, REMOVED_FROM_SPACE, APP_COMMAND, CARD_CLICKED events silently 400'd. Empirically observed: this puts Google's add-on framework into back-off that eventually stops MESSAGE delivery too, matching #13856's symptom (DMs work, space events never arrive).

Changes

  • Broaden the extractor to handle all known chat.<kind>Payload variants.
  • Derive event.type from which payload variant is populated; prefer rawObj.type when the host sets one explicitly.
  • Add console.warn diagnostics on every 400 return path. Silent 400s are how this bug stayed in production unnoticed — operators had to grep journalctl with no signal pointing them at the parser. Structured logs surface rootKeys, chatKeys, hostApp so the next regression is obvious.

Test plan

  • Added test: addedToSpacePayload accepted (previously 400'd)
  • Added test: explicit rawObj.type overrides derived type
  • Existing messagePayload happy-path test still passes
  • Manual smoke test against a live deployment: DM, group @-mention, ADDED_TO_SPACE all flow through the agent without 400s

Related issues

🤖 Generated with Claude Code

Closes openclaw#13856.

The add-on event payload extractor in parseGoogleChatInboundPayload only
handled chat.messagePayload and hardcoded type='MESSAGE'. Per Google's
Workspace Add-on docs (https://developers.google.com/workspace/add-ons/chat/event-objects),
event kind is signaled by which 'chat.<kind>Payload' field is populated;
the framework does NOT include a top-level 'type' field.

Effect of the bug:
- ADDED_TO_SPACE / REMOVED_FROM_SPACE / APP_COMMAND / CARD_CLICKED events
  were dropped silently (returned HTTP 400 'invalid payload' before
  reaching the agent). This matches user reports in openclaw#13856 (space events
  not received) and explains why DMs worked but group spaces didn't —
  every space membership change emits one of these add-on events first,
  and the failures put Google's add-on framework into a back-off that
  eventually stops MESSAGE delivery too.

Fix:
- Broaden the extractor to handle messagePayload, addedToSpacePayload,
  removedFromSpacePayload, appCommandPayload, buttonClickedPayload,
  cardClickedPayload.
- Derive event.type from which payload variant is populated, and prefer
  rawObj.type when the host actually sets one.
- Add console.warn diagnostics on every 400 return path. Silent 400s are
  why the original bug stayed in production unnoticed; structured logs
  make the failure obvious in journalctl/stderr without patching dist.

Test coverage:
- Added two cases to monitor-webhook.test.ts: addedToSpacePayload accepted
  with derived type ADDED_TO_SPACE, and explicit rawObj.type beats the
  derived type.

Related issues: openclaw#13856, openclaw#35095, openclaw#53888, openclaw#57386.
@openclaw-barnacle openclaw-barnacle Bot added channel: googlechat Channel integration: googlechat size: S triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 12, 2026
@clawsweeper

clawsweeper Bot commented May 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

Summary
The PR broadens Google Chat Workspace Add-on payload parsing in extensions/googlechat/src/monitor-webhook.ts and adds monitor webhook tests for derived add-on event types.

Reproducibility: yes. from source inspection: a current-main Workspace Add-on request with commonEventObject.hostApp: "CHAT" and chat.addedToSpacePayload is not transformed because only messagePayload is handled, then it lacks a root type and returns HTTP 400. I did not run tests because this was a read-only review.

Real behavior proof
Needs real behavior proof before merge: The PR body only asserts a manual smoke test and includes no screenshot, recording, terminal output, copied live output, linked artifact, or redacted logs; the contributor should add redacted proof to the PR body so a fresh ClawSweeper review can run, or ask a maintainer to comment @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, ask a maintainer to comment @clawsweeper re-review.

Next step before merge
Human review is needed because the external PR lacks real behavior proof and overlaps an active Google Chat parser issue/PR cluster, even though the code correction itself is narrow.

Security
Cleared: The diff only changes Google Chat parser logic and tests; I found no concrete security or supply-chain regression.

Review findings

  • [P2] Handle widgetUpdatedPayload too — extensions/googlechat/src/monitor-webhook.ts:100-103
Review details

Best possible solution:

Accept add-on envelopes through the full Google-documented Chat payload union, return successful acknowledgements for non-message events, keep message dispatch unchanged, and consolidate the result with the open Google Chat parser cluster.

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

Yes from source inspection: a current-main Workspace Add-on request with commonEventObject.hostApp: "CHAT" and chat.addedToSpacePayload is not transformed because only messagePayload is handled, then it lacks a root type and returns HTTP 400. I did not run tests because this was a read-only review.

Is this the best way to solve the issue?

No: the direction is right, but the patch should include the documented widgetUpdatedPayload path and provide real behavior proof before merge. Consolidating with the open canonical Google Chat parser issue is the cleaner maintainer path.

Full review comments:

  • [P2] Handle widgetUpdatedPayload too — extensions/googlechat/src/monitor-webhook.ts:100-103
    Google's Workspace Add-on Chat payload union also includes chat.widgetUpdatedPayload, and the conversion guide maps it to WIDGET_UPDATED. This branch still leaves that payload with payload undefined, so autocomplete widget events fall through to the event-type guard and return 400, the same class of add-on failure this PR is meant to prevent. Add the widget-updated variant and a focused regression case. (developers.google.com)
    Confidence: 0.91

Overall correctness: patch is incorrect
Overall confidence: 0.86

Acceptance criteria:

  • pnpm test extensions/googlechat/src/monitor-webhook.test.ts
  • pnpm test extensions/googlechat/src/monitor.webhook-routing.test.ts

What I checked:

  • Current main parser only unwraps messagePayload: On current main, parseGoogleChatInboundPayload only transforms Workspace Add-on events when rawObj.chat?.messagePayload is present and hardcodes type: "MESSAGE"; an add-on payload such as addedToSpacePayload remains wrapped and then fails the string event-type guard with HTTP 400. (extensions/googlechat/src/monitor-webhook.ts:63, 3cbc88970120)
  • Current main intentionally ignores non-message events after parsing: The runtime processor returns for any event type other than MESSAGE, so the parser fix should accept lifecycle/non-message add-on envelopes and let them ack without dispatching agent work. (extensions/googlechat/src/monitor.ts:50, 3cbc88970120)
  • PR diff broadens the extractor but misses a documented variant: The patch handles messagePayload, addedToSpacePayload, removedFromSpacePayload, appCommandPayload, buttonClickedPayload, and cardClickedPayload, but does not add widgetUpdatedPayload; that leaves one official add-on payload path returning 400. (extensions/googlechat/src/monitor-webhook.ts:100, 8ab296d7bd5c)
  • Upstream Google add-on contract includes widgetUpdatedPayload: Google's Workspace Add-ons event object docs list chat.widgetUpdatedPayload in the Chat payload union, and the conversion guide maps it to WIDGET_UPDATED. (developers.google.com)
  • Related cluster remains active: GitHub search found the open canonical Google Chat parser issue and a related open PR: Google Chat add-on payload parsing rejects valid space events and wildcard group allowlist still blocks senders #65007 and fix(googlechat): accept add-on space lifecycle payload variants #65058. This PR has broader coverage than that older PR, so it should be consolidated rather than closed as a simple duplicate.
  • Real behavior proof is not attached: The PR body claims a live smoke test, but the PR has no attached logs, terminal output, screenshots, recordings, or linked artifacts; the only issue comment fetched was the ClawSweeper placeholder.

Likely related people:

  • steipete: Introduced the split monitor-webhook.ts parser path in commit 1c9deed and has several recent Google Chat monitor/runtime refactors touching the same files. (role: recent area contributor and feature-history owner; confidence: high; commits: 1c9deeda97ce, 827b0de0ce74, 05eda57b3c72; files: extensions/googlechat/src/monitor-webhook.ts, extensions/googlechat/src/monitor.ts)
  • luyao618: Auth rejection logging and appPrincipal warning work in the same webhook parser/test area landed in commit 0e50fee. (role: adjacent fix author; confidence: medium; commits: 0e50fee9967c; files: extensions/googlechat/src/monitor-webhook.ts, extensions/googlechat/src/monitor-webhook.test.ts, extensions/googlechat/src/monitor.ts)
  • vincentkoc: Recent Google Chat webhook pre-auth body handling and inbound callback hardening touched this path around the add-on request lifecycle. (role: webhook hardening contributor; confidence: medium; commits: 5e78c8bc95d8, a47722de7e3c; files: extensions/googlechat/src/monitor-webhook.ts)
  • shakkernerd: Recently tightened Google Chat webhook test assertions in the same test file, making them a useful reviewer for regression coverage shape. (role: recent test contributor; confidence: medium; commits: bc22ce8fdd97; files: extensions/googlechat/src/monitor-webhook.test.ts)

Remaining risk / open question:

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

@yfge

This comment was marked as spam.

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

Labels

channel: googlechat Channel integration: googlechat size: S 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.

[Bug]: Google Chat: Space webhook events not received by OpenClaw (DMs work correctly)

2 participants