fix(telegram): classify PTB heartbeat transport errors - #62098
Merged
kshitijk4poor merged 2 commits intoJul 10, 2026
Merged
Conversation
kshitijk4poor
force-pushed
the
salvage/62060-telegram-network
branch
from
July 10, 2026 13:53
9b318a9 to
177d66e
Compare
kshitijk4poor
enabled auto-merge (rebase)
July 10, 2026 13:53
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Telegram polling heartbeat failures wrapped by python-telegram-bot now enter the existing reconnect ladder, while semantic Bot API errors remain non-retryable.
Based on #62060 by @liuhao1024. The substantive production commit preserves the contributor's authorship.
What changed
get_me()and the pending-update probe through the shared_looks_like_network_error()classifier.BadRequestinherits fromNetworkErrordespite being a permanent request error._schedule_polling_recovery()for existing-task dedupe and background-task lifecycle tracking.Divergence from #62060
The original inline
isinstance(NetworkError)classifier was not retained because it also matched PTBBadRequest. Its negative test used an unrealistic mock hierarchy and passed on unmodified main. This salvage fixes the shared classifier instead of adding a second policy.Verification
98 passedacross Telegram reconnect, pending-update, and thread-fallback suites.NetworkError,TimedOut-> one recoveryBadRequest,InvalidToken,Forbidden,RetryAfter-> no recoveryCloses #62060
Closes #62047