Skip to content

fix(telegram): route image documents through photo handling (salvage #19023)#21173

Merged
teknium1 merged 2 commits into
mainfrom
salvage/pr-19023
May 7, 2026
Merged

fix(telegram): route image documents through photo handling (salvage #19023)#21173
teknium1 merged 2 commits into
mainfrom
salvage/pr-19023

Conversation

@teknium1

@teknium1 teknium1 commented May 7, 2026

Copy link
Copy Markdown
Contributor

Closes #19023 via salvage.

Summary

Telegram delivers screenshots / image shares as document (not photo). Current code rejects them with 'Unsupported document type .png'. This salvage routes image documents through the existing photo cache + batching path.

Changes

  • gateway/platforms/telegram.py: add image MIME/ext tables; in the document handler, detect image payloads (ext or image/* mime) and route them via cache_image_from_bytes + _enqueue_photo_event. Move the 20 MB size check above the image branch so image documents cannot bypass it.
  • tests/gateway/test_telegram_documents.py: regression tests for PNG and malformed image documents.

Improvements during salvage

  • Normalize doc.mime_type to lowercase once at the top so uppercase MIME (IMAGE/PNG) is handled symmetrically with the filename extension.

Validation

scripts/run_tests.sh tests/gateway/test_telegram_documents.py → 41 passed.

Original author: @mrcoferland.

@teknium1 teknium1 merged commit e7eb07c into main May 7, 2026
10 of 11 checks passed
@teknium1 teknium1 deleted the salvage/pr-19023 branch May 7, 2026 11:51
@github-actions

github-actions Bot commented May 7, 2026

Copy link
Copy Markdown
Contributor

🔎 Lint report: salvage/pr-19023 vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 7448 on HEAD, 7448 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 3914 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@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 7, 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