Skip to content

fix(googlechat): accept add-on space lifecycle payload variants - #65058

Closed
Yanhu007 wants to merge 1 commit into
openclaw:mainfrom
Yanhu007:fix/googlechat-addon-payload-variants
Closed

Yanhu007 wants to merge 1 commit into
openclaw:mainfrom
Yanhu007:fix/googlechat-addon-payload-variants

Conversation

@Yanhu007

Copy link
Copy Markdown
Contributor

The Google Chat add-on payload parser only handled chat.messagePayload, rejecting valid addedToSpacePayload and removedFromSpacePayload events as "invalid payload".

Expand parseGoogleChatInboundPayload to recognise all three payload variants and map to correct event types (MESSAGE, ADDED_TO_SPACE, REMOVED_FROM_SPACE).

Partially addresses #65007

The Google Chat add-on payload parser only handled
chat.messagePayload, rejecting valid addedToSpacePayload and
removedFromSpacePayload events with "invalid payload".

Expand parseGoogleChatInboundPayload to recognise all three
payload variants and map them to the correct event types.

Partially addresses openclaw#65007
@openclaw-barnacle openclaw-barnacle Bot added channel: googlechat Channel integration: googlechat size: XS labels Apr 12, 2026
@greptile-apps

greptile-apps Bot commented Apr 12, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR expands parseGoogleChatInboundPayload in the Google Chat extension to handle addedToSpacePayload and removedFromSpacePayload add-on lifecycle events in addition to messagePayload, fixing rejections that previously surfaced as "invalid payload" for those event types. The three-branch dispatch is functionally correct for all payload shapes that Google Chat currently emits, since the three payload fields are mutually exclusive in practice.

Confidence Score: 5/5

Safe to merge; the only finding is a P2 logic-clarity issue that does not affect current Google Chat payloads.

All three real-world payload variants are handled correctly. The type-determination issue only manifests if both messagePayload and addedToSpacePayload appear simultaneously in one envelope, which the Google Chat API does not produce. No security, data-loss, or auth-boundary concerns introduced.

extensions/googlechat/src/monitor-webhook.ts — minor type-determination coupling worth cleaning up.

Prompt To Fix All With AI
This is a comment left during a code review.
Path: extensions/googlechat/src/monitor-webhook.ts
Line: 68-73

Comment:
**Type determination decoupled from payload selection**

`messagePayload` is resolved with `??` (preferring `chat.messagePayload`), but the event type is determined by checking `chat.addedToSpacePayload` independently. If both fields were ever present in the same envelope, the event would be extracted from `messagePayload` but labelled `"ADDED_TO_SPACE"`. The `?? undefined` tail is also redundant since `??` already returns `undefined` when the left side is `null`/`undefined`.

A clearer approach keeps selection and labelling in the same branch:

```suggestion
    if (chat.messagePayload) {
      eventPayload = {
        type: "MESSAGE",
        space: chat.messagePayload.space,
        message: chat.messagePayload.message,
        user: chat.user,
        eventTime: chat.eventTime,
      };
      addOnBearerToken =
        typeof rawObj.authorizationEventObject?.systemIdToken === "string"
          ? rawObj.authorizationEventObject.systemIdToken.trim()
          : "";
    } else if (chat.addedToSpacePayload) {
      eventPayload = {
        type: "ADDED_TO_SPACE",
        space: chat.addedToSpacePayload.space,
        message: chat.addedToSpacePayload.message,
        user: chat.user,
        eventTime: chat.eventTime,
      };
      addOnBearerToken =
        typeof rawObj.authorizationEventObject?.systemIdToken === "string"
          ? rawObj.authorizationEventObject.systemIdToken.trim()
          : "";
    } else if (chat.removedFromSpacePayload) {
      eventPayload = {
        type: "REMOVED_FROM_SPACE",
        space: chat.removedFromSpacePayload.space,
        user: chat.user,
        eventTime: chat.eventTime,
      };
      addOnBearerToken =
        typeof rawObj.authorizationEventObject?.systemIdToken === "string"
          ? rawObj.authorizationEventObject.systemIdToken.trim()
          : "";
    }
```

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

Reviews (1): Last reviewed commit: "fix(googlechat): accept add-on space lif..." | Re-trigger Greptile

Comment on lines +68 to +73
const messagePayload =
chat.messagePayload ?? chat.addedToSpacePayload ?? undefined;
const isRemoval = !messagePayload && chat.removedFromSpacePayload != null;
if (messagePayload) {
eventPayload = {
type: chat.addedToSpacePayload ? "ADDED_TO_SPACE" : "MESSAGE",

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 Type determination decoupled from payload selection

messagePayload is resolved with ?? (preferring chat.messagePayload), but the event type is determined by checking chat.addedToSpacePayload independently. If both fields were ever present in the same envelope, the event would be extracted from messagePayload but labelled "ADDED_TO_SPACE". The ?? undefined tail is also redundant since ?? already returns undefined when the left side is null/undefined.

A clearer approach keeps selection and labelling in the same branch:

Suggested change
const messagePayload =
chat.messagePayload ?? chat.addedToSpacePayload ?? undefined;
const isRemoval = !messagePayload && chat.removedFromSpacePayload != null;
if (messagePayload) {
eventPayload = {
type: chat.addedToSpacePayload ? "ADDED_TO_SPACE" : "MESSAGE",
if (chat.messagePayload) {
eventPayload = {
type: "MESSAGE",
space: chat.messagePayload.space,
message: chat.messagePayload.message,
user: chat.user,
eventTime: chat.eventTime,
};
addOnBearerToken =
typeof rawObj.authorizationEventObject?.systemIdToken === "string"
? rawObj.authorizationEventObject.systemIdToken.trim()
: "";
} else if (chat.addedToSpacePayload) {
eventPayload = {
type: "ADDED_TO_SPACE",
space: chat.addedToSpacePayload.space,
message: chat.addedToSpacePayload.message,
user: chat.user,
eventTime: chat.eventTime,
};
addOnBearerToken =
typeof rawObj.authorizationEventObject?.systemIdToken === "string"
? rawObj.authorizationEventObject.systemIdToken.trim()
: "";
} else if (chat.removedFromSpacePayload) {
eventPayload = {
type: "REMOVED_FROM_SPACE",
space: chat.removedFromSpacePayload.space,
user: chat.user,
eventTime: chat.eventTime,
};
addOnBearerToken =
typeof rawObj.authorizationEventObject?.systemIdToken === "string"
? rawObj.authorizationEventObject.systemIdToken.trim()
: "";
}
Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/googlechat/src/monitor-webhook.ts
Line: 68-73

Comment:
**Type determination decoupled from payload selection**

`messagePayload` is resolved with `??` (preferring `chat.messagePayload`), but the event type is determined by checking `chat.addedToSpacePayload` independently. If both fields were ever present in the same envelope, the event would be extracted from `messagePayload` but labelled `"ADDED_TO_SPACE"`. The `?? undefined` tail is also redundant since `??` already returns `undefined` when the left side is `null`/`undefined`.

A clearer approach keeps selection and labelling in the same branch:

```suggestion
    if (chat.messagePayload) {
      eventPayload = {
        type: "MESSAGE",
        space: chat.messagePayload.space,
        message: chat.messagePayload.message,
        user: chat.user,
        eventTime: chat.eventTime,
      };
      addOnBearerToken =
        typeof rawObj.authorizationEventObject?.systemIdToken === "string"
          ? rawObj.authorizationEventObject.systemIdToken.trim()
          : "";
    } else if (chat.addedToSpacePayload) {
      eventPayload = {
        type: "ADDED_TO_SPACE",
        space: chat.addedToSpacePayload.space,
        message: chat.addedToSpacePayload.message,
        user: chat.user,
        eventTime: chat.eventTime,
      };
      addOnBearerToken =
        typeof rawObj.authorizationEventObject?.systemIdToken === "string"
          ? rawObj.authorizationEventObject.systemIdToken.trim()
          : "";
    } else if (chat.removedFromSpacePayload) {
      eventPayload = {
        type: "REMOVED_FROM_SPACE",
        space: chat.removedFromSpacePayload.space,
        user: chat.user,
        eventTime: chat.eventTime,
      };
      addOnBearerToken =
        typeof rawObj.authorizationEventObject?.systemIdToken === "string"
          ? rawObj.authorizationEventObject.systemIdToken.trim()
          : "";
    }
```

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

@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.

Keep open: current main and the latest release still lack Google Chat add-on added/removed-space lifecycle payload parsing, and no merged or viable open replacement owns that exact fix. This PR is not merge-ready because the branch is conflicting against current main and still lacks inspectable real Google Chat behavior proof.

Root-cause cluster
Relationship: canonical
Canonical: #65058
Summary: This PR is the only open exact candidate found for the Google Chat Workspace Add-on added/removed-space lifecycle parser gap; related issues and PRs are closed, broader, or adjacent.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Canonical path: Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review.

So I’m closing this here because the remaining work is already tracked in the canonical issue.

Review details

Best possible solution:

Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review.

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

Yes at source level. Current main only unwraps chat.messagePayload and chat.buttonClickedPayload; an add-on envelope containing chat.addedToSpacePayload or chat.removedFromSpacePayload lacks a root event type after parsing and reaches the invalid payload guard.

Is this the best way to solve the issue?

No as currently submitted. The parser boundary is the right place, but the best fix must be rebased over current main's card-click parser, covered by tests, and backed by real Google Chat proof.

Security review:

Security review cleared: Cleared: the diff only changes Google Chat payload normalization and adds no dependency, workflow, secret, package, or code-execution surface.

AGENTS.md: found and applied where relevant.

What I checked:

  • stale F-rated PR: PR was opened 2026-04-12T00:10:24Z, is older than 60 days, and the latest review rated it F.
  • proof blocker: real behavior proof is missing and proof tier is F, so this branch is not merge-ready without contributor follow-up.
  • no human follow-up: live comments and timeline hydrated by apply contain no non-automation activity after the ClawSweeper review.

Likely related people:

  • iHildy: Authored the beta Google Chat channel and the Google Workspace Add-on event-format support that first added this parser behavior. (role: introduced feature area; confidence: high; commits: b76cd6695d11, 5991bed32e67; files: extensions/googlechat/src/monitor.ts, extensions/googlechat/src/auth.ts, extensions/googlechat/src/types.ts)
  • steipete: Committed the original Google Chat add-on work and authored the later split that moved webhook parsing into monitor-webhook.ts. (role: webhook parser boundary refactor author; confidence: high; commits: 5991bed32e67, 1c9deeda97ce; files: extensions/googlechat/src/monitor-webhook.ts, extensions/googlechat/src/monitor.ts, extensions/googlechat/src/monitor-access.ts)
  • kevinslin: Authored the current native Google Chat approval-card work that added buttonClickedPayload and CARD_CLICKED handling in the same parser path this stale branch now conflicts with. (role: recent adjacent feature owner; confidence: high; commits: d7759c6a35ac; files: extensions/googlechat/src/monitor-webhook.ts, extensions/googlechat/src/monitor-webhook.test.ts, extensions/googlechat/src/types.ts)
  • luyao618: Authored recent Google Chat webhook auth rejection logging and appPrincipal diagnostics in the same webhook and test area. (role: recent adjacent webhook contributor; confidence: medium; commits: 0e50fee9967c; files: extensions/googlechat/src/monitor-webhook.ts, extensions/googlechat/src/monitor-webhook.test.ts, extensions/googlechat/src/monitor.ts)
  • shakkernerd: Recently tightened Google Chat webhook assertions in the primary test file likely to receive lifecycle parser regression coverage. (role: recent test contributor; confidence: medium; commits: bc22ce8fdd97; files: extensions/googlechat/src/monitor-webhook.test.ts)

Codex review notes: model internal, reasoning high; reviewed against 4e6933c84f18.

@clawsweeper clawsweeper Bot added 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. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels May 19, 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 19, 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.

@RomneyDa

Copy link
Copy Markdown
Member

Heads up: this PR needs to be updated against current main before the new required Dependency Guard check can pass.

@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

Copy link
Copy Markdown

Closing due to inactivity.
If you believe this PR should be revived, post in #clawtributors 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 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: XS stale Marked as stale due to inactivity 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.

2 participants