fix(gateway): log runtime-status write failures with rate-limiting (salvage #21158)#21285
Merged
Conversation
…logs Extracts the three try/write_runtime_status/except-log blocks into a shared _write_runtime_status_safe() helper. On failure, logs the first occurrence per (platform, context) at warning level and downgrades subsequent failures to debug — so a persistently broken status dir (permissions, ENOSPC) doesn't spam the log on every Telegram reconnect. Uses getattr for the _status_write_logged set so test harnesses that skip __init__ (object.__new__(Adapter)) don't break. Follow-up to the salvaged #21158.
Contributor
🔎 Lint report:
|
1 task
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
Gateway platform adapters now surface runtime-status write failures to the log instead of silently swallowing them, with rate-limiting so a persistently broken status dir doesn't spam on every reconnect.
Changes
gateway/platforms/base.py: salvage @wabrent's original three-hunk change (replaceexcept: passwithlogger.warningin_mark_connected/_mark_disconnected/_set_fatal_error), then consolidate the three try/write/except blocks into a shared_write_runtime_status_safe()helper.Improvements during salvage
getattrfor the per-instance_status_write_loggedset so test harnesses that bypass__init__viaobject.__new__(Adapter)(a common pattern intests/gateway/) still work.Validation
scripts/run_tests.sh tests/gateway/ -k 'base or platform': 335 passed, 7 skipped.PermissionErrorfromwrite_runtime_status()called 5× on "connected" + 2× on "fatal" → exactly 2 WARNINGs, 5 DEBUGs. Happy path: zero log output.object.__new__(Adapter)harness does not crash ongetattrfallback.Closes #21158 via salvage. Co-authored by @wabrent.