Skip to content

fix: reduce Telegram log spam from polling and conflict errors (#10027) - #10046

Merged
Soulter merged 1 commit into
AstrBotDevs:masterfrom
nina-ysml:fix/10027-telegram-log-spam
Sep 14, 2026
Merged

fix: reduce Telegram log spam from polling and conflict errors (#10027)#10046
Soulter merged 1 commit into
AstrBotDevs:masterfrom
nina-ysml:fix/10027-telegram-log-spam

Conversation

@nina-ysml

@nina-ysml nina-ysml commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Problem

The Telegram adapter floods the log in two ways:

  1. Polling requests: python-telegram-bot performs getUpdates through httpx, and httpx logs every request at INFO level. httpx/httpcore were missing from LogManager._NOISY_LOGGER_LEVELS, so those per-request lines (one every ~10s) leaked into the log.
  2. Conflict errors: _on_polling_error logged a full traceback for every polling error, including non-network errors such as Conflict (which happens when two bot instances poll the same token).

Fix

  • Add httpx and httpcore to _NOISY_LOGGER_LEVELS so their request-level logging is suppressed.
  • In _on_polling_error, log a concise one-line message for non-network errors and keep the full traceback only for NetworkError, which still needs it for the recovery logic.

Notes

The 409 Conflict itself is caused by two bot instances polling the same token and is not an AstrBot bug; this change only stops it from spamming a full traceback.

Closes #10027

Summary by Sourcery

Bug Fixes:

  • Reduce Telegram log spam by suppressing routine httpx and httpcore request logs and shortening non-network polling errors to one-line messages.

…otDevs#10027)

Telegram long-polling floods the log in two ways:

1. python-telegram-bot performs getUpdates through httpx, which logs every request at INFO level. httpx/httpcore were missing from LogManager._NOISY_LOGGER_LEVELS, so those per-request lines (one every ~10s) leaked through.

2. _on_polling_error logged a full traceback for every polling error, including non-network errors such as Conflict (two bot instances polling the same token). Log a concise one-line message for non-network errors and keep the traceback only for NetworkError, which still needs it for recovery.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Approved.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@kilisamemarisaaa kilisamemarisaaa left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed head 48bb8eb. Non-network polling errors still return before recovery accounting and now emit a concise message without exc_info, while NetworkError keeps traceback logging and the existing rebuild-threshold path. I also verified the noisy logger configuration sets httpx/httpcore child loggers to WARNING without suppressing warnings or errors. The Telegram adapter tests (29), API logger tests (6), full Ruff checks, and the repository CI matrix are green. I found no correctness blocker.

@Soulter
Soulter merged commit e79c0d7 into AstrBotDevs:master Sep 14, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] telegram轮询和报错占满日志

3 participants