fix(gateway): guard NoneType in Telegram reconnect after network error (#55992) - #120
Open
hashbender wants to merge 1 commit into
Open
fix(gateway): guard NoneType in Telegram reconnect after network error (#55992)#120hashbender wants to merge 1 commit into
hashbender wants to merge 1 commit into
Conversation
|
Review Complete Risk: 🟢 Low (12/100) — no findings · 12 LOC across 1 file Single-file PR modifies the Telegram adapter's reconnection logic in plugins/platforms/telegram/adapter.py. The change replaces direct _app.stop() calls with a supervised stop sequence and adds a fatal error escalation path. No findings meet the confidence threshold. Files Reviewed (1 files) |
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.
Problem
After sustained network errors, the Telegram adapter's
_handle_polling_network_errorreconnect handler sleeps with exponential backoff (5s–60s) before callingstart_polling(). During that sleep window the supervisor may tear down the adapter —disconnect()setsself._app = None(line 3028).The existing
stop()call at line 1777 was already guarded:But
start_polling()at line 1785 was not guarded:This crashes with
'NoneType' object has no attribute 'updater', silently killing the reconnect loop. The gateway process stays alive (state file says "running" + "connected") but never processes another Telegram message.Fix
Add a
Noneguard for bothself._appandself._app.updaterbefore thestart_polling()call, matching the pattern already used forstop(). If the app was destroyed during the reconnect delay, log a warning and abort cleanly.Reproduction
httpx.ConnectErrormultiple timesself._app = None)self._app.updater.start_polling()Testing
python3 -m py_compile plugins/platforms/telegram/adapter.py— syntax OKstop()guard at line 1777Fixes NousResearch#55992
Mirror-of: NousResearch#56028
NousResearch#56028