fix(telegram): fall back to document on any send_photo failure, not just dim errors#19714
Merged
Conversation
…ust dim errors Broadens the existing fallback (previously only fired for Photo_invalid_dimensions) to cover every send_photo exception class: rate limits, corrupt file markers, format edge cases. The expected dimension case still logs at INFO (document is the right path); all other cases log at WARNING with exc_info so they're visible in logs. If send_document itself fails, we still fall back to the base adapter's text-only 'Image: /path' rendering as a last resort. Salvage of #15837 — original PR author QifengKuang proposed the broader try/except-style fallback. Adapted to keep the existing INFO-vs-WARNING log split for dimension errors (the expected case). Co-authored-by: QifengKuang <k2767567815@gmail.com>
3 tasks
10 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.
Salvage of #15837 by @QifengKuang onto current main, broadening the existing dimension-specific fallback.
Summary
Earlier work (#19630) added document-fallback for the specific
Photo_invalid_dimensionserror on send_photo. #15837 correctly pointed out that other failures (rate limits on the photo endpoint, corrupt-looking image markers, format edge cases) also benefit from the same fallback — degrading to a text-only "Image: /path" from the base adapter is strictly worse for users than attempting a document send.Broaden the fallback to fire on ANY send_photo exception. Keep the dimension case logging at INFO (document is the expected path for screenshots / tall images). Log all other failures at WARNING with exc_info so they stay visible. If send_document itself fails, still fall back to the base adapter as a last resort.
Adaptation during salvage
Original PR unconditionally logged at WARNING. Kept the INFO-vs-WARNING split for known-benign dimension errors so log noise stays quiet for the expected case.
Changes
Validation
scripts/run_tests.sh tests/gateway/ -k telegram → 379 passed
Original PR: #15837