Skip to content

fix(telegram): fallback to document when photo dimensions exceed limits#15728

Closed
ee-blog wants to merge 1 commit into
NousResearch:mainfrom
ee-blog:fix/telegram-photo-dimensions-fallback
Closed

fix(telegram): fallback to document when photo dimensions exceed limits#15728
ee-blog wants to merge 1 commit into
NousResearch:mainfrom
ee-blog:fix/telegram-photo-dimensions-fallback

Conversation

@ee-blog

@ee-blog ee-blog commented Apr 25, 2026

Copy link
Copy Markdown
Contributor

Problem

Telegram's send_photo API has dimension limits — the sum of width + height must not exceed 10000px. When sending large screenshots or tall images (e.g., full-page screenshots), the API returns Photo_invalid_dimensions error.

Solution

Catch the Photo_invalid_dimensions error in send_image_file() and automatically fallback to send_document() which:

  • Has no dimension limits
  • Only has a 50MB size limit
  • Sends the image as a file attachment instead of a photo

This is similar to the existing 5MB URL fallback (commit 542faf2) but handles local files with dimension issues instead of URL size issues.

Related

  • Similar approach to #542faf22 which handles >5MB URL images
  • Complements the existing download-retry fallback for URLs

Testing

Tested with a full-page screenshot (height > 5000px) that previously failed with Photo_invalid_dimensions. After this fix, the image was successfully sent as a document file.

Telegram's send_photo has dimension limits (sum of width+height <= 10000px).
When sending large screenshots or tall images, the API returns
'Photo_invalid_dimensions' error.

Fix: Catch this specific error in send_image_file() and automatically
fallback to send_document() which has no dimension limits (only 50MB size).

This is similar to the existing 5MB URL fallback (commit 542faf2) but
handles local files with dimension issues instead of URL size issues.
@teknium1

teknium1 commented May 4, 2026

Copy link
Copy Markdown
Contributor

Salvaged via #19630 onto current main - your commit authorship was preserved. Thanks!

@teknium1 teknium1 closed this 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