Skip to content

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

Closed
neeravmakwana wants to merge 1 commit into
openclaw:mainfrom
neeravmakwana:fix/telegram-expired-approval-callback
Closed

neeravmakwana wants to merge 1 commit into
openclaw:mainfrom
neeravmakwana:fix/telegram-expired-approval-callback

Conversation

@neeravmakwana

Copy link
Copy Markdown
Contributor

Summary

  • Treat stale Telegram exec approval callback resolutions as handled, non-retryable callbacks.
  • Clear the inline keyboard for expired approval buttons when possible so persisted spooled updates can drain.
  • Preserve retry behavior for generic approval resolver failures and other transient callback failures.

Root cause

Telegram approval callbacks currently wrap every approval resolver failure in the retryable callback error. When the resolver returns unknown or expired approval id, polling-mode isolated ingress keeps the persisted spooled update for retry, so the same expired callback can be replayed forever across gateway restarts.

Linked issue

Fixes #82347.

Why this is safe

The fix reuses the existing runtime-enforced isApprovalNotFoundError classifier that other channel approval paths use for expired approvals. It only changes the already-failed stale approval-id path from retryable to handled; transient resolver errors still throw and retry as before.

Security/runtime controls unchanged

Telegram sender authorization, exec approval target checks, plugin fallback authorization, approval decisions, and approval resolver policy are unchanged. This does not rely on prompt text; the behavior is gated by the structured/runtime approval-not-found error classifier.

Real behavior proof

Behavior addressed: expired Telegram approval callbacks no longer bubble a retryable handler error after the approval id is gone.

Real environment tested: local OpenClaw source checkout with Telegram plugin unit harness.

Exact steps or command run after this patch: npm_config_manage_package_manager_versions=false pnpm test extensions/telegram/src/bot.test.ts extensions/telegram/src/bot.create-telegram-bot.test.ts -- --reporter=verbose -t "expired approval callbacks|retries exec approval callbacks"

Evidence after fix: the focused Telegram shard passed with 2 matching tests, including the new expired approval callback regression and the existing generic resolver retry regression.

Observed result after fix: stale approval callbacks resolve without throwing, acknowledge the callback, clear the inline keyboard, and do not send Telegram chat error messages; generic resolver failures still retry.

What was not tested: live Telegram polling with real credentials was not run in this local pass.

Verification

  • git diff --check origin/main...HEAD
  • npm_config_manage_package_manager_versions=false pnpm test extensions/telegram/src/bot.test.ts extensions/telegram/src/bot.create-telegram-bot.test.ts -- --reporter=verbose -t "expired approval callbacks|retries exec approval callbacks"
  • npm_config_manage_package_manager_versions=false pnpm check:changed (fails on unrelated pre-existing lint in extensions/openrouter/image-generation-provider.ts: typescript(no-redundant-type-constituents) for OpenRouterChatCompletionResponse | unknown; changed-file guards and extension typechecks passed before that lint failure)

Out of scope

  • Live Telegram credentialed E2E/package QA.
  • Broader callback retry policy changes outside stale approval ids.
  • Unrelated OpenRouter lint cleanup.

AI-assisted

Yes.

Made with Cursor

@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram size: S triage: mock-only-proof Candidate: PR proof only shows tests, mocks, snapshots, lint, typecheck, or CI. labels May 16, 2026
@clawsweeper

clawsweeper Bot commented May 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

Summary
The branch changes Telegram approval callback handling to treat approval-not-found resolver errors as handled after clearing inline buttons, and updates the focused Telegram unit regression.

Reproducibility: yes. source-level: current main wraps expired approval resolver errors as retryable callback failures, and isolated polling keeps any thrown spooled update for retry. The linked issue also provides concrete Telegram polling-mode steps and logs.

Real behavior proof
Needs real behavior proof before merge: The PR body reports only local Telegram unit-harness tests, so after-fix real Telegram or bot-to-bot behavior proof is still missing. 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
Contributor action is needed to add real Telegram or equivalent bot-to-bot proof; there is no narrow code repair request because the diff itself looks correct.

Security
Cleared: The diff changes Telegram callback error classification and tests only; it does not broaden authorization, secrets, dependencies, workflows, or package execution paths.

Review details

Best possible solution:

Merge the focused callback classification fix once after-fix real Telegram or bot-to-bot proof is added, then let the linked bug close through the PR.

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

Yes, source-level: current main wraps expired approval resolver errors as retryable callback failures, and isolated polling keeps any thrown spooled update for retry. The linked issue also provides concrete Telegram polling-mode steps and logs.

Is this the best way to solve the issue?

Yes, the PR's approach is the narrow maintainable fix: classify approval-not-found resolver failures before retry wrapping while preserving generic resolver retries. The remaining blocker is proof quality, not an observed code defect in the diff.

Acceptance criteria:

  • Add after-fix real Telegram Desktop, bot-to-bot QA, terminal/live output, or redacted log proof showing an expired approval callback drains without retrying and does not block later Telegram messages.
  • Keep focused regression coverage for expired approval callbacks and generic resolver retry behavior.

What I checked:

Likely related people:

  • Peter Steinberger: Visible current history attributes the Telegram approval callback retry wrapper and isApprovalNotFoundError helper to ba8b4377f74b957e6f98c4dab06747f092d99648; git log --follow also shows recent Telegram isolated-ingress backlog work by the same author. (role: introduced behavior and recent adjacent owner; confidence: medium; commits: ba8b4377f74b, 25a8f5f3f852; files: extensions/telegram/src/bot-handlers.runtime.ts, extensions/telegram/src/bot.test.ts, extensions/telegram/src/bot.create-telegram-bot.test.ts)

Remaining risk / open question:

  • The PR body only reports unit-harness proof; the Telegram callback transport path still needs real Telegram or equivalent bot-to-bot evidence that the expired callback drains and no longer wedges polling.

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

@clawsweeper clawsweeper Bot added the mantis: telegram-visible-proof Mantis should capture Telegram visible proof. label May 16, 2026
@yfge

This comment was marked as spam.

@joshavant

Copy link
Copy Markdown
Collaborator

Thanks @neeravmakwana for opening the focused fix PR. Your diagnosis was right: stale Telegram exec approval callbacks needed to be classified as handled/non-retryable when the approval resolver reports unknown or expired approval id, while preserving retry behavior for real transient callback failures.

We ended up landing #82455 as the maintainer fix. It follows the same core direction and adds the target-only fallback guard for legacy plugin approval buttons, so stale approval ids drain without accidentally clearing ambiguous legacy fallback buttons.

Closing this PR as superseded by the landed fix in #82455 / merge commit 9162349. Thanks again for moving the issue forward.

@joshavant joshavant closed this May 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: telegram Channel integration: telegram mantis: telegram-visible-proof Mantis should capture Telegram visible proof. size: S triage: mock-only-proof Candidate: PR proof only shows tests, mocks, snapshots, lint, typecheck, or CI.

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

3 participants