Skip to content

fix(bug): Google Chat stale approval cards keep retrying after approv… - #98457

Closed
WYH1597650869 wants to merge 1 commit into
openclaw:mainfrom
WYH1597650869:fix_bug
Closed

WYH1597650869 wants to merge 1 commit into
openclaw:mainfrom
WYH1597650869:fix_bug

Conversation

@WYH1597650869

Copy link
Copy Markdown

What Problem This Solves

Fixes an issue where Google Chat approval card clicks treat APPROVAL_NOT_FOUND gateway errors the same as transient failures. When a user clicks a stale/expired approval card after the backing approval was already resolved or deleted elsewhere, the click handler incorrectly releases the card token for retry instead of consuming it.

Concrete problem: Users can repeatedly click the same expired approval card, causing the gateway to receive multiple resolution attempts for an approval that no longer exists. Each click appears to "work" (returns true) but the gateway logs show repeated APPROVAL_NOT_FOUND errors for the same approval ID.

Reproduction:

  1. Register a Google Chat approval card binding
  2. Click the card after the approval was resolved/expired elsewhere
  3. Gateway returns APPROVAL_NOT_FOUND
  4. Click the same stale card again → retry loop

Why This Change Was Made

The fix distinguishes between terminal errors (approval no longer exists) and transient errors (gateway temporarily unavailable):

  • APPROVAL_NOT_FOUND → Terminal state: consume the token, log that the approval is expired/stale, and return handled without retrying
  • Other errors → Transient: release the token for retry and re-throw the error

The change was made in extensions/googlechat/src/approval-card-click.ts:86-98 by adding a type check in the catch block:

catch (error) {
  if (isApprovalNotFoundError(error)) {
    // Terminal state: approval no longer exists. Consume the token and ignore future clicks.
    completeGoogleChatApprovalCardBinding(token);
    params.target.runtime.log?.(
      `[${params.target.account.accountId}] googlechat approval expired/stale id=${consumed.approvalId} decision=${consumed.decision}`,
    );
    return true;
  }
  // Transient error: release for retry.
  releaseGoogleChatApprovalCardBinding(token);
  throw error;
}

This follows the same pattern used by other approval channels (Telegram, Matrix, Signal, etc.) which already handle APPROVAL_NOT_FOUND as a terminal condition.

User Impact

Google Chat users: Expired/stale approval cards now fail gracefully on first click instead of creating a retry loop. Users will see a log message indicating the approval has expired, and subsequent clicks on the same card are silently ignored.

Operators/Admins: Gateway logs will no longer show repeated APPROVAL_NOT_FOUND errors for the same approval ID from stale card clicks.

No breaking changes: The fix only affects error handling behavior. Successful approval flows remain unchanged.

Evidence

Test Run

pnpm test extensions/googlechat/src/approval-card-click.test.ts

[test] starting test/vitest/vitest.extension-messaging.config.ts

RUN v4.1.8 /home/0668001433/python_project/openclaw

✓ extension-messaging extensions/googlechat/src/approval-card-click.test.ts (7 tests) 31ms

Test Files 1 passed (1)
Tests 7 passed (7)
Start at 14:10:44
Duration 22.91s (transform 15.53s, setup 837ms, import 21.66s, tests 31ms, environment 0ms)

Related Files

  • Modified: extensions/googlechat/src/approval-card-click.ts:86-98
  • Test: extensions/googlechat/src/approval-card-click.test.ts:291-332 (existing test validates the fix)
  • Error detection: src/infra/approval-errors.ts
  • Binding management: extensions/googlechat/src/approval-card-actions.ts

@clawsweeper

clawsweeper Bot commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the contribution. This PR still needs the requested real-behavior proof, and the branch has been idle since that ask.

Close this stale external PR: it has had no author update since July 1, 2026, carries the dated status: 📣 needs proof request, and contains only mocked test output rather than after-fix channel behavior proof. The underlying current-main bug remains concretely tracked in the canonical issue, so closing this outdated, dirty branch does not discard the report.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #98432
Summary: This PR is an unproven, now-stale candidate implementation for the source-reproducible Google Chat stale-card retry bug tracked by the open canonical issue.

Members:

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

So I’m closing this for now to keep the review queue honest. Please reopen or open a fresh PR with real-behavior proof (a live run, logs, or a reproducible validation transcript) and it will be reviewed again.

Review details

Best possible solution:

Implement the narrow terminal-error classification against the current typed Google Chat click handler under #98432: consume only isApprovalNotFoundError bindings, preserve retry behavior for all other failures, add a current-main regression test, and provide redacted end-to-end or ephemeral-gateway behavior proof.

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

Yes, by source inspection: have the canonical Gateway resolver return an approval-not-found error for a valid Google Chat card token, then invoke the same card action twice. Current main releases the token for every thrown resolver error, and the second click can therefore retry it.

Is this the best way to solve the issue?

No for this branch. Its terminal-error idea is narrow and sound, but current main now uses typed canonical approval results and card rendering; the dirty branch must be rebuilt with a current-main regression test and real behavior proof.

Security review:

Security review cleared: The submitted diff only changes channel-local error classification and tests; no concrete credential, authorization, dependency, or supply-chain regression is introduced.

AGENTS.md: found and applied where relevant.

What I checked:

  • Current source still exposes the reported retry path: The current Google Chat handler releases its claimed card-token binding for every resolver exception. The Gateway returns an approval-not-found error when no durable approval record is visible, so an APPROVAL_NOT_FOUND response still follows the retry path unless the handler classifies it as terminal. (extensions/googlechat/src/approval-card-click.ts:96, b8a6ea12cc2f)
  • Current approval service distinguishes resolved from missing approvals: The canonical approval.resolve handler returns applied: false with the durable winner for an existing non-pending record, but emits approval-not-found when the record is absent. The current Google Chat tests cover the former first-answer-wins result, not the missing-record error path. (src/gateway/server-methods/approval.ts:379, b8a6ea12cc2f)
  • Current-main rewrite supersedes the submitted implementation shape: Git blame attributes the resolver/result and terminal-card flow in the current click handler to commit 4e484da05258f5a01a56fc74832a7906efd2d2db; compared with the PR head, current main removed the branch's old error-runtime import and replaced its legacy fallback call with typed canonical approval resolution and terminal-card rendering. (extensions/googlechat/src/approval-card-click.ts:81, 4e484da05258)
  • Proof gate and stalled state: The PR body supplies a focused Vitest transcript only; it has no after-fix Google Chat or ephemeral gateway harness evidence. The status: 📣 needs proof label was applied on July 1, 2026, the sole head commit is also from July 1, and GitHub reports the branch as dirty against main. (4164337458d7)
  • Canonical remaining work: The open canonical issue documents the same current-main mechanism and expected terminal token consumption, while the earlier duplicate PR was closed unmerged. The issue is the appropriate place for a current-main repair or replacement PR.

Likely related people:

  • Shakker: Current-main blame attributes the canonical Google Chat approval-click resolver/result flow to this contributor's recent commit. (role: recent area contributor; confidence: high; commits: 4e484da05258; files: extensions/googlechat/src/approval-card-click.ts)
  • Kevin Lin: Introduced the native Google Chat approval-card surface that owns the token and card-click behavior. (role: feature introducer; confidence: high; commits: d7759c6a35ac; files: extensions/googlechat/src/approval-card-click.ts, extensions/googlechat/src/approval-card-actions.ts)
  • Peter Steinberger: History associates this contributor with the typed cross-surface approval action work that the current canonical resolver follows. (role: cross-surface approval refactor contributor; confidence: medium; commits: 7a456e362d0b; files: src/infra/approval-gateway-resolver.ts, extensions/googlechat/src/approval-card-click.ts)

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

@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. P2 Normal backlog priority with limited blast radius. labels Jul 1, 2026
@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 Jul 23, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Aug 2, 2026
@clawsweeper

clawsweeper Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper applied the proposed close for this PR.

@clawsweeper clawsweeper Bot closed this Aug 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: googlechat Channel integration: googlechat P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: S stale Marked as stale due to inactivity status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant