Skip to content

fix(telegram): classify and dedup post-reconnect probe failures (#63243) - #63247

Closed
SilentKnight87 wants to merge 1 commit into
NousResearch:mainfrom
SilentKnight87:fix/telegram-post-reconnect-probe-classification
Closed

fix(telegram): classify and dedup post-reconnect probe failures (#63243)#63247
SilentKnight87 wants to merge 1 commit into
NousResearch:mainfrom
SilentKnight87:fix/telegram-post-reconnect-probe-classification

Conversation

@SilentKnight87

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes #63243 — closes the gap #62098 left in the third Telegram probe. _verify_polling_after_reconnect() (the one-shot probe scheduled 60s after a successful reconnect) still routed every get_me() failure into _handle_polling_network_error() with no classification, awaited it directly (bypassing the _polling_error_task in-flight guard every other recovery entry point honors), and logged the raw error.

Related Issue

Closes #63243

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✅ Tests (adding or improving test coverage)

Changes Made

plugins/platforms/telegram/adapter.py_verify_polling_after_reconnect() only:

  • Probe failures are now classified with the shared _looks_like_network_error() (the fix(telegram): classify PTB heartbeat transport errors #62098 classifier): connectivity errors enter the recovery ladder; auth/validation errors (InvalidToken, BadRequest, …) log once (redacted) and do not trigger reconnect churn.
  • Both recovery entry points (wedged-updater and probe-failure) now route through the existing _schedule_polling_recovery() instead of awaiting the handler inline — picking up the in-flight _polling_error_task guard (no more concurrent stop/drain/start_polling sequences → no self-inflicted 409 loop), the has_fatal_error guard, and _background_tasks bookkeeping.
  • The probe-failure log line uses _redact_telegram_error_text(), matching sibling sites (PTB transport error text can embed the bot-token request URL).

Tests (tests/gateway/test_telegram_network_reconnect.py):

  • New: auth errors from the probe schedule no recovery; a probe failure during an in-flight recovery does not start a second one. Both verified to fail on unfixed main (revert + rerun).
  • Updated the three existing probe tests to the scheduled-task semantics (they now also assert _background_tasks registration).

How to Test

scripts/run_tests.sh tests/gateway/test_telegram_network_reconnect.py tests/gateway/test_telegram_pending_update_probe.py -- -q

51 passed.

Checklist

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits
  • I searched for existing PRs to make sure this isn't a duplicate (gap confirmed present at 7b5ba20)
  • My PR contains only changes related to this fix (one function + its tests)
  • I've added tests for my changes (verified non-vacuous against unfixed main)
  • I've tested on my platform: macOS
  • I've considered cross-platform impact (exception classification only)

@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery platform/telegram Telegram bot adapter sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages P1 High — major feature broken, no workaround labels Jul 12, 2026
@kshitijk4poor

Copy link
Copy Markdown
Collaborator

Merged via #64368. Your commit cherry-picked with authorship preserved (rebase-merge). Thanks for fixing the third probe path that #62098 missed — routing through _schedule_polling_recovery with the shared classifier is the right pattern.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery 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.

bug(telegram): post-reconnect probe routes auth errors into reconnect ladder and bypasses the recovery dedup guard (gap left by #62098)

3 participants