Skip to content

fix(googlechat): handle Add-on non-MESSAGE events (ADDED_TO_SPACE, REMOVED_FROM_SPACE) - #33967

Closed
novan wants to merge 1 commit into
openclaw:mainfrom
novan:fix/googlechat-addon-space-events-v5
Closed

novan wants to merge 1 commit into
openclaw:mainfrom
novan:fix/googlechat-addon-space-events-v5

Conversation

@novan

@novan novan commented Mar 4, 2026

Copy link
Copy Markdown
Contributor

Problem

When a Chat app is configured as a Google Workspace Add-on, Google Chat sends events in the Add-on format (commonEventObject.hostApp === "CHAT").

Previously, only MESSAGE events (chat.messagePayload) were transformed. Other event types like ADDED_TO_SPACE and REMOVED_FROM_SPACE were not handled, causing:

  • 400 'invalid payload' responses from OpenClaw
  • Google Chat entering a backoff/suspended state and completely stopping event delivery to the endpoint

Fix (monitor-webhook.ts)

  • Handle ADDED_TO_SPACE events via chat.addedToSpacePayload
  • Handle REMOVED_FROM_SPACE events via chat.removedFromSpacePayload
  • Move addOnBearerToken extraction before event-type branching (applies to all Add-on events)
  • For unknown Add-on event types: return unknownAddonEvent flag instead of responding 200 immediately — caller verifies token first, then responds 200 after successful auth (prevents authentication bypass)

Security

The unknown-event 200 response is only sent after bearer token verification, consistent with how all other event types are handled.

How to Reproduce

  1. Configure a Chat app as a Google Workspace Add-on (HTTP endpoint)
  2. Add the bot to a Google Chat space
  3. Google sends ADDED_TO_SPACE in Add-on format → OpenClaw returns 400
  4. Google Chat stops sending any further events to the endpoint

Reference

…response

When the Chat app is configured as a Google Workspace Add-on, Google Chat
sends events in Add-on format (commonEventObject.hostApp=CHAT). Previously,
only MESSAGE events (chat.messagePayload) were handled. Other event types
like ADDED_TO_SPACE and REMOVED_FROM_SPACE caused 400 errors, making Google
Chat stop delivering events to the endpoint entirely.

Changes:
- Handle ADDED_TO_SPACE events (chat.addedToSpacePayload)
- Handle REMOVED_FROM_SPACE events (chat.removedFromSpacePayload)
- Move addOnBearerToken extraction before event-type branching
- For unknown Add-on event types: return unknownAddonEvent flag so caller
  can respond 200 only after token verification (prevents auth bypass)
@openclaw-barnacle openclaw-barnacle Bot added channel: googlechat Channel integration: googlechat size: S labels Mar 4, 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: deab8fda3d

ℹ️ 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".

} else {
// Unknown Add-on event type: return flag so caller can respond 200
// after verifying the token (avoid auth bypass)
return { ok: false, unknownAddonEvent: true, addOnBearerToken };

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 Respond for unknown Add-on events in header-auth flow

Returning unknownAddonEvent here does not set an HTTP response, but createGoogleChatWebhookRequestHandler's header-bearer path still short-circuits on if (!parsed.ok) return true. For requests that carry an Authorization header and an Add-on event type outside the handled set, the handler exits without res.end(...), so the client sees a hanging request until timeout (and likely retries/backoff) instead of a clear success/error response.

Useful? React with 👍 / 👎.

@greptile-apps

greptile-apps Bot commented Mar 4, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR successfully fixes a gap in the Google Workspace Add-on webhook handler by adding support for ADDED_TO_SPACE and REMOVED_FROM_SPACE event types, which previously caused 400 responses and triggered Google Chat's backoff/suspension mechanism.

Key improvements:

  • parseGoogleChatInboundPayload now correctly handles chat.addedToSpacePayload and chat.removedFromSpacePayload in addition to chat.messagePayload.
  • Bearer-token extraction is correctly moved before event-type branching so it applies consistently to all Add-on events.
  • Unknown Add-on events return { ok: false, unknownAddonEvent: true, addOnBearerToken }, allowing the caller to verify the token before responding 200, preventing authentication bypass.
  • The else branch properly gates the unknown-event response behind token verification.

The implementation is correct and well-structured for the intended use case.

Confidence Score: 4/5

  • Safe to merge. The PR correctly implements support for new Google Workspace Add-on event types with proper authentication gating and handles all reachable code paths correctly.
  • The core fix is sound: new event types are properly parsed, bearer token extraction is correctly positioned before branching, and unknown-event responses are gated behind token verification. The implementation correctly handles all scenarios that occur in practice with Google Chat's Add-on event format. No functional issues detected in the reachable code paths.
  • No files require special attention.

Last reviewed commit: deab8fd

@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 13, 2026
@openclaw-barnacle

Copy link
Copy Markdown

Closing due to inactivity.
If you believe this PR should be revived, post in #pr-thunderdome-dangerzone on Discord to talk to a maintainer.
That channel is the escape hatch for high-quality PRs that get auto-closed.

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 stale Marked as stale due to inactivity

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant