Skip to content

fix(telegram): survive getUpdates conflicts in isolated polling ingress - #91997

Merged
obviyus merged 2 commits into
mainfrom
telegram-isolated-polling-conflict
Jun 12, 2026
Merged

obviyus merged 2 commits into
mainfrom
telegram-isolated-polling-conflict

Conversation

@obviyus

@obviyus obviyus commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

A getUpdates 409 Conflict (second poller on the same bot token, or a stale webhook) kills the whole Telegram account in isolated ingress mode — the default. The ingress worker flattens Bot API errors into a message string, so the parent session cannot tell a conflict apart from a fatal 401 and rethrows out of runUntilAbort (extensions/telegram/src/polling-session.ts). The core supervisor then burns one of MAX_RESTART_ATTEMPTS = 10 (preserved across auto-restarts, src/gateway/server-channels.ts) and eventually gives up permanently — while the classic polling cycle has always handled the same 409 in-session with webhook re-clear, transport rotation (#69787), and a duplicate-poller hint.

Changes:

  • The ingress worker preserves the Bot API error_code on getUpdates failures and posts it in poll-error messages (typed worker contract).
  • The isolated cycle treats 409 like the classic path: re-clear webhook, rotate transport, restart with backoff + the duplicate-poller hint, instead of crashing the account. Fatal errors (e.g. 401) still propagate.
  • The conflict hint and stall detection now reach channel status (lastError/connected), not just the gateway log. Previously a classic-path conflict loop showed connected: true with no error for up to 30 minutes, and the actionable diagnosis never reached openclaw channels status.

Verification

  • node scripts/run-vitest.mjs extensions/telegram/src/polling-session.test.ts — 54 passed.
  • Regression proof (prod files swapped to origin/main, new tests kept): restarts isolated ingress on a getUpdates conflict instead of crashing the account fails with the account-crash (runUntilAbort rejects with Conflict: terminated by other getUpdates request); the status assertions in the classic conflict and stall tests fail with no patch published. All pass with this branch's code.
  • Testbox check:changed green (tbx_01ktsa6ds3121d18zk2mq7470k): typecheck extensions + extension tests, oxlint, import cycles, guards.
  • Not tested: live two-poller 409 against the real Bot API; the worker runtime file itself has no direct test (boots as a worker thread; covered via the typed message contract and session-level tests).

@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram size: S maintainer Maintainer-authored PR labels Jun 10, 2026
@obviyus obviyus self-assigned this Jun 10, 2026
@clawsweeper

clawsweeper Bot commented Jun 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed June 10, 2026, 2:04 PM ET / 18:04 UTC.

Summary
The PR carries Telegram Bot API error codes across the isolated ingress worker boundary, restarts isolated polling on 409 conflicts with webhook cleanup and transport rotation, and exposes polling conflicts and stalls through channel status.

PR surface: Source +48, Tests +103. Total +151 across 4 files.

Reproducibility: yes. Current main’s getUpdates-only worker drops the numeric Bot API code, and the parent rethrows a 409 because it is not classified as a recoverable network error, which gives a high-confidence source reproduction path.

Review metrics: none identified.

Merge readiness
Overall: 🦪 silver shellfish
Proof: 🦪 silver shellfish
Patch quality: 🐚 platinum hermit
Result: blocked until real behavior proof from a real setup is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Provide a redacted live two-poller or stale-webhook 409 trace showing recovery and openclaw channels status; redact tokens, phone numbers, IPs, and non-public endpoints.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR provides focused regression tests and Testbox checks, but explicitly lacks after-fix proof from a real Telegram Bot API 409; add a redacted terminal or log trace, then update the PR body to trigger review or ask a maintainer for @clawsweeper re-review.

Risk before merge

  • [P1] The contributor did not exercise a real Telegram two-poller or stale-webhook 409, so the external API shape and end-to-end recovery/status behavior remain proven only by controlled tests.
  • [P1] The PR has the protected maintainer label, so landing requires explicit maintainer handling even though the technical review found no blocking defect.

Maintainer options:

  1. Decide the mitigation before merge
    Keep the structured error code in the worker contract and the shared in-session recovery policy, then verify one redacted real Bot API 409 run shows webhook cleanup, transport rotation, continued polling, and accurate channel status before landing.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P1] A maintainer should review the protected-label PR and require the missing real Telegram behavior proof before merge; no narrow code repair is currently indicated.

Security
Cleared: The patch adds no dependency, secret, permission, downloaded artifact, package-resolution, or supply-chain execution change.

Review details

Best possible solution:

Keep the structured error code in the worker contract and the shared in-session recovery policy, then verify one redacted real Bot API 409 run shows webhook cleanup, transport rotation, continued polling, and accurate channel status before landing.

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

Yes. Current main’s getUpdates-only worker drops the numeric Bot API code, and the parent rethrows a 409 because it is not classified as a recoverable network error, which gives a high-confidence source reproduction path.

Is this the best way to solve the issue?

Yes. Preserving the structured API code at the existing worker boundary and applying the already-established classic polling recovery invariant is narrower and safer than parsing error text or changing gateway-wide restart policy.

AGENTS.md: found and applied where relevant.

Codex review notes: reasoning high; reviewed against aeb537c28620.

Label changes

Label changes:

  • add P1: The default isolated Telegram ingress can exhaust supervisor retries and permanently stop a real account from receiving updates after a 409 conflict.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR provides focused regression tests and Testbox checks, but explicitly lacks after-fix proof from a real Telegram Bot API 409; add a redacted terminal or log trace, then update the PR body to trigger review or ask a maintainer for @clawsweeper re-review.

Label justifications:

  • P1: The default isolated Telegram ingress can exhaust supervisor retries and permanently stop a real account from receiving updates after a 409 conflict.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR provides focused regression tests and Testbox checks, but explicitly lacks after-fix proof from a real Telegram Bot API 409; add a redacted terminal or log trace, then update the PR body to trigger review or ask a maintainer for @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +48, Tests +103. Total +151 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 3 62 14 +48
Tests 1 103 0 +103
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 165 14 +151

What I checked:

  • Current-main failure path: Current main flattens worker getUpdates failures to a message and treats a 409 as a non-recoverable worker failure, allowing runUntilAbort to reject and the gateway supervisor to consume persistent restart attempts. (extensions/telegram/src/telegram-ingress-worker.runtime.ts:195, aeb537c28620)
  • Patch behavior: The branch preserves numeric Bot API error_code values, detects only errorCode 409 in the getUpdates-only worker path, marks the transport dirty, re-enables webhook cleanup, publishes the actionable status error, and restarts with the existing bounded backoff while other fatal errors still propagate. (extensions/telegram/src/polling-session.ts:1011, 5d366be1974e)
  • Regression coverage: The added tests cover isolated 409 recovery without session rejection, transport rotation and webhook re-clear, fatal-error propagation, classic conflict status, and polling-stall status; the PR body reports 54 focused tests and a green Testbox changed check. (extensions/telegram/src/polling-session.test.ts:2357, 5d366be1974e)
  • Sibling-path alignment: Classic polling already treats getUpdates conflicts as in-session recovery by clearing webhook state, rotating the transport, publishing an error, and backing off; the isolated branch now follows the same invariant rather than creating a parallel policy. (extensions/telegram/src/polling-session.ts:540, 5d366be1974e)
  • Feature provenance: The current polling-session ownership trail includes the polling split and transport-rebuild work, which are the most relevant prior design changes for this patch. (extensions/telegram/src/polling-session.ts:300, 0c0f1e34cba0)
  • Release state: The regression remains present in current main and latest release v2026.6.5; this PR is new work rather than an already-implemented or superseded change. (extensions/telegram/src/polling-session.ts:1002, 5181e4f7c82b)

Likely related people:

  • Peter Steinberger: Authored the polling/SDK surface split and several adjacent Telegram polling refactors on the current implementation path. (role: polling architecture contributor; confidence: high; commits: 0c0f1e34cba0, b171e4211787, 6a2c5b2b54a7; files: extensions/telegram/src/polling-session.ts)
  • pkuGeo: Introduced the adjacent transport-rebuild behavior for stalled polling cycles that this 409 recovery path intentionally mirrors. (role: transport recovery contributor; confidence: high; commits: e035a0d98c91; files: extensions/telegram/src/polling-session.ts)
  • wangchunyue: Recently changed Telegram polling watchdog behavior and is relevant to the restart and liveness lifecycle touched here. (role: recent polling reliability contributor; confidence: medium; commits: dd61171f5b3e; files: extensions/telegram/src/polling-session.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. 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. labels Jun 10, 2026
@obviyus
obviyus force-pushed the telegram-isolated-polling-conflict branch from 5d366be to 95343e8 Compare June 12, 2026 04:56
@obviyus
obviyus merged commit d481994 into main Jun 12, 2026
155 checks passed
@obviyus
obviyus deleted the telegram-isolated-polling-conflict branch June 12, 2026 04:59
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 P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: S 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