Skip to content

fix(telegram): fall back to document on any send_photo failure, not just dim errors#19714

Merged
teknium1 merged 1 commit into
mainfrom
hermes/hermes-8c54fd4a
May 4, 2026
Merged

fix(telegram): fall back to document on any send_photo failure, not just dim errors#19714
teknium1 merged 1 commit into
mainfrom
hermes/hermes-8c54fd4a

Conversation

@teknium1

@teknium1 teknium1 commented May 4, 2026

Copy link
Copy Markdown
Contributor

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_dimensions error 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

  • gateway/platforms/telegram.py: dimension-aware logging + try/except document fallback on any photo failure (+35/-11)

Validation

scripts/run_tests.sh tests/gateway/ -k telegram → 379 passed

Original PR: #15837

…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>
@teknium1 teknium1 merged commit 69fc6d9 into main May 4, 2026
7 of 10 checks passed
@teknium1 teknium1 deleted the hermes/hermes-8c54fd4a branch May 4, 2026 11:54
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery platform/telegram Telegram bot adapter labels May 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists platform/telegram Telegram bot adapter type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants