Skip to content

fix(telegram): drop expired approval callbacks - #82455

Merged
joshavant merged 2 commits into
mainfrom
fix/telegram-expired-approval-callback-spool
May 16, 2026
Merged

joshavant merged 2 commits into
mainfrom
fix/telegram-expired-approval-callback-spool

Conversation

@joshavant

Copy link
Copy Markdown
Collaborator

Summary

Fixes #82347.

  • Treat Telegram approval callback unknown or expired approval id errors as terminal instead of retryable so isolated polling removes the spooled update.
  • Clear inline approval buttons for expired callbacks only when safe: explicit plugin approvals or configured approvers; target-only bare-ID fallback misses keep legacy plugin approval buttons intact.
  • Add focused Telegram tests for expired approver callbacks and target-only fallback preservation.

Verification

  • node scripts/run-vitest.mjs extensions/telegram/src/bot.test.ts -t "drops target-only approval not-found misses without clearing legacy fallback buttons|drops expired approval callbacks for configured approvers after clearing buttons"
  • node scripts/run-vitest.mjs extensions/telegram/src/bot.create-telegram-bot.test.ts -t "retries exec approval callbacks after a bubbled resolution failure"
  • node scripts/run-vitest.mjs src/infra/approval-errors.test.ts
  • git diff --check
  • codex review --uncommitted (final pass: no actionable bugs)
  • Current-main reproduction before fix: Crabbox AWS run_0fc16a32632c, lease cbx_74628cb44ad1.
  • Final patched live proof: Crabbox AWS run_50cde10f39b0, lease cbx_caf441a2b36d.

Real behavior proof

Behavior addressed: Telegram isolated polling no longer retries an expired approval callback forever after Telegram returns an expired/invalid callback query and the gateway returns unknown or expired approval id.

Real environment tested: AWS Crabbox with real Telegram Bot API credentials leased from Convex using credential kind telegram; gateway ran with Telegram polling enabled and a mock OpenAI-compatible provider.

Exact steps or command run after this patch: pnpm crabbox:run -- --idle-timeout 90m --ttl 180m --timing-json --env-from-profile /private/tmp/openclaw-82347-convex.local.env --allow-env OPENCLAW_QA_CONVEX_SITE_URL,OPENCLAW_QA_CONVEX_SECRET_CI --script .artifacts/qa-e2e/issue-82347/repro-telegram-expired-callback.mjs

Evidence after fix: Crabbox run run_50cde10f39b0 seeded a stale approval callback update into telegram/ingress-spool-default, observed the real Telegram answerCallbackQuery 400 and gateway unknown or expired approval id, then confirmed beforeRestart.spoolExists=false, beforeRestart.retryFailures=0, afterRestart.spoolExists=false, and afterRestart.retryFailures=0.

Observed result after fix: The stale callback was consumed once, did not reappear after gateway restart, and a later normal Telegram message received a bot reply (postStormMessage.replyFound=true).

What was not tested: A real human Telegram Desktop button press was not used because no telegram-user credentials were available; the live proof used bot credentials plus a seeded stale callback update to exercise the same Telegram Bot API, gateway resolver, and isolated polling spool path.

@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram size: S maintainer Maintainer-authored PR labels May 16, 2026
@clawsweeper

clawsweeper Bot commented May 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

Summary
The PR makes Telegram approval-not-found callback failures terminal, conditionally clears expired approval buttons, adds focused Telegram regression tests, and updates the changelog.

Reproducibility: yes. The linked bug gives concrete Telegram polling steps, the PR body reports a current-main Crabbox reproduction, and current-main source shows approval-not-found failures enter the retry-preserving spool path.

Real behavior proof
Sufficient (live_output): The PR body includes after-fix AWS Crabbox live output with real Telegram Bot API credentials, a seeded stale callback, observed runtime errors, spool removal across restart, and a later successful bot reply.

Next step before merge
The protected maintainer label and clean review make this a maintainer review and landing decision, not a ClawSweeper repair-lane item.

Security
Cleared: No concrete security or supply-chain issue was found; the diff only changes Telegram callback error handling, focused tests, and changelog text.

Review details

Best possible solution:

Keep the fix scoped to Telegram callback error classification and use the landed result as the canonical resolution for #82347 and the duplicate PR #82388.

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

Yes. The linked bug gives concrete Telegram polling steps, the PR body reports a current-main Crabbox reproduction, and current-main source shows approval-not-found failures enter the retry-preserving spool path.

Is this the best way to solve the issue?

Yes. Reusing the shared approval-not-found classifier inside the Telegram approval callback handler is the narrow maintainable fix, while generic resolver failures remain retryable and ambiguous target-only fallback buttons are preserved.

Acceptance criteria:

  • node scripts/run-vitest.mjs extensions/telegram/src/bot.test.ts -t "drops target-only approval not-found misses without clearing legacy fallback buttons|drops expired approval callbacks for configured approvers after clearing buttons"
  • node scripts/run-vitest.mjs extensions/telegram/src/bot.create-telegram-bot.test.ts -t "retries exec approval callbacks after a bubbled resolution failure"
  • node scripts/run-vitest.mjs src/infra/approval-errors.test.ts
  • git diff --check

What I checked:

  • protected-label routing: The provided GitHub context shows this PR is open and labeled maintainer, so cleanup automation should not close it even though the patch looks narrow and validated. (27af96536625)
  • current-main retry root cause: Current main wraps every approval callback resolver failure in TelegramRetryableCallbackError, including unknown or expired approval id, before this PR's special case. (extensions/telegram/src/bot-handlers.runtime.ts:2074, dccf5f684211)
  • current-main spool retention path: Current main deletes a spooled Telegram update only after bot.handleUpdate succeeds; thrown handler errors are logged and retained for retry. (extensions/telegram/src/polling-session.ts:325, dccf5f684211)
  • approval-not-found classifier contract: The shared classifier already recognizes structured approval-not-found gateway errors and the legacy unknown or expired approval id message, matching the PR's intended boundary. (src/infra/approval-errors.ts:18, dccf5f684211)
  • PR diff review: The downloaded PR diff imports the shared classifier, returns without retrying approval-not-found callbacks, and only clears buttons for plugin approvals or configured approvers. (extensions/telegram/src/bot-handlers.runtime.ts:2077, 27af96536625)
  • focused regression coverage: The PR adds a configured-approver expired callback test and changes the target-only fallback expectation so the update is dropped without clearing legacy plugin fallback buttons. (extensions/telegram/src/bot.test.ts:866, 27af96536625)

Likely related people:

  • joshavant: Prior merged Telegram bot-handler work touched the same handler file, so the PR author also appears in current-main history for the affected surface. (role: recent area contributor; confidence: medium; commits: a2963f51d538; files: extensions/telegram/src/bot-handlers.runtime.ts)
  • steipete: Recent Telegram bot-handler and polling-session commits touch the same callback and spool-adjacent surfaces, and shortlog shows substantial recent history in these files. (role: recent adjacent owner; confidence: medium; commits: 1109abc94701, 25a8f5f3f852; files: extensions/telegram/src/bot-handlers.runtime.ts, extensions/telegram/src/polling-session.ts)
  • gumadeiras: The shared approval-not-found classifier reused by this PR traces to prior core approval error deduplication work. (role: approval classifier contributor; confidence: medium; commits: e627f53d24a9; files: src/infra/approval-errors.ts, src/plugin-sdk/error-runtime.ts, src/infra/approval-gateway-resolver.ts)

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

@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 16, 2026
@joshavant
joshavant force-pushed the fix/telegram-expired-approval-callback-spool branch from 34ed6d0 to d224d0e Compare May 16, 2026 05:24
@joshavant
joshavant force-pushed the fix/telegram-expired-approval-callback-spool branch from d224d0e to 5bd6786 Compare May 16, 2026 05:33
@clawsweeper clawsweeper Bot added the mantis: telegram-visible-proof Mantis should capture Telegram visible proof. label May 16, 2026
@joshavant
joshavant force-pushed the fix/telegram-expired-approval-callback-spool branch from 5bd6786 to 27af965 Compare May 16, 2026 05:43
@joshavant
joshavant merged commit 9162349 into main May 16, 2026
102 of 108 checks passed
@joshavant
joshavant deleted the fix/telegram-expired-approval-callback-spool branch May 16, 2026 06:43
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
* fix(telegram): drop expired approval callbacks

* changelog: credit expired Telegram callback fix
galiniliev pushed a commit to galiniliev/openclaw that referenced this pull request May 25, 2026
* fix(telegram): drop expired approval callbacks

* changelog: credit expired Telegram callback fix
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
* fix(telegram): drop expired approval callbacks

* changelog: credit expired Telegram callback fix
sablehead pushed a commit to sablehead/openclaw that referenced this pull request Jun 10, 2026
* fix(telegram): drop expired approval callbacks

* changelog: credit expired Telegram callback fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: telegram Channel integration: telegram maintainer Maintainer-authored PR mantis: telegram-visible-proof Mantis should capture Telegram visible proof. proof: sufficient ClawSweeper judged the real behavior proof convincing. size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Telegram channel blocked by infinite retry loop on expired callback_query approval

1 participant