Skip to content

fix(telegram): require getUpdates progress before polling is healthy - #64381

Merged
kshitijk4poor merged 1 commit into
NousResearch:mainfrom
kshitijk4poor:fix/63581-salvage
Jul 14, 2026
Merged

fix(telegram): require getUpdates progress before polling is healthy#64381
kshitijk4poor merged 1 commit into
NousResearch:mainfrom
kshitijk4poor:fix/63581-salvage

Conversation

@kshitijk4poor

Copy link
Copy Markdown
Collaborator

Summary

Salvage of #63581 (CI blocked for first-time contributor). Makes Telegram polling health depend on successful getUpdates progress rather than get_me() return. PTB's Updater.start_polling() can return after creating its retry task but before the first getUpdates request succeeds — a cold start or reconnect could log "Connected", clear degraded send protection, and remain alive-but-deaf indefinitely.

Changes

  • Instruments only the dedicated PTB get_updates_request (general Bot API calls cannot mark polling healthy).
  • Binds every polling start to an immutable generation inherited by PTB child tasks, so late requests from old pollers cannot affect their replacement.
  • Routes cold start, network recovery, and conflict recovery through one bounded start primitive + one owned progress verifier.
  • Keeps outbound delivery fail-closed while polling is degraded; only matching-generation HTTP 2xx getUpdates progress clears it and resets counters.
  • Fences teardown before recovery can re-arm; cancels and awaits recovery/verifier owners.
  • Restores correct health/mode transitions for sequential same-adapter webhook reconnects.
  • Preserves persistent 409 retry escalation after start_polling() returns; resets counter only after real polling progress.

Attribution

Cherry-picked from @arnispiekus's #63581 with authorship preserved. Built on top of #63247 (SilentKnight87) which was merged via #64368.

Validation

  • 22 passed in test_telegram_polling_progress.py
  • 7 passed in test_telegram_polling_progress_ptb.py (PTB integration, real request objects)
  • 51 passed in test_telegram_network_reconnect.py
  • 15 passed in test_telegram_conflict.py
  • 9 passed in test_telegram_send_path_health.py
  • ruff + py_compile clean
  • Note: PTB tests must run in separate processes (subprocess-per-file isolation) — cross-file mock leakage causes failures when run in the same process. CI runs them separately.

AUTHOR_MAP

Added arnispiekus mapping in a separate chore commit (required for check-attribution).

@alt-glitch alt-glitch added type/bug Something isn't working P1 High — major feature broken, no workaround comp/plugins Plugin system and bundled plugins platform/telegram Telegram bot adapter sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages labels Jul 14, 2026
@kshitijk4poor
kshitijk4poor enabled auto-merge (rebase) July 14, 2026 12:10
For PR NousResearch#63581 salvage (telegram: require getUpdates progress before
polling is healthy).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/plugins Plugin system and bundled plugins P1 High — major feature broken, no workaround platform/telegram Telegram bot adapter sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants