fix(telegram): preserve PNG attachments via document delivery - #1
Open
sasoder wants to merge 1 commit into
Open
Conversation
sasoder
force-pushed
the
fix/telegram-preserve-png-delivery
branch
2 times, most recently
from
April 6, 2026 12:03
ad5ba79 to
4e96efc
Compare
sasoder
force-pushed
the
fix/telegram-preserve-png-delivery
branch
from
April 6, 2026 13:49
c5deea7 to
fd5a21e
Compare
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.
What does this PR do?
Fixes Telegram delivery for local PNG files emitted by gateway responses.
Found this bug while working with image/game assets. I wanted Hermes to send back a png so I could inspect it, but Telegram delivered it through the photo path and it came back as a jpeg instead of the original png file, which compresses the image and loses the transparency I was trying to verify.
I looked for a cleaner Telegram-side way to fix this, but I don't think there is one. The Bot API has
sendPhoto()for photos andsendDocument()for the original file.The rest of the behavior stays the same. Other platforms keep using the normal image path, and Telegram still sends non-png local images as photos. The png preservation now lives inside Telegram's
send_image_file()implementation instead of adding a new base-adapter hook for one platform-specific behavior.Related Issue
I did not find an exact issue for this specific png preservation problem.
Type of Change
Changes Made
TelegramAdapter.send_image_file()so local.pngfiles are sent throughsend_document()and keep the original file.send_photo()path.send_image_file(), and Telegram decides the exact Telegram delivery method internally.send_image_file()tests so the photo-path tests use.jpgfixtures instead of.pngfixtures.print()withlogger.error(..., exc_info=True)while touching the same delivery code.How to Test
MEDIA:/absolute/path/to/file.png.jpg, and confirm it still uses the normal photo/image delivery pathVerification
source .venv/bin/activate && python -m pytest tests/gateway/test_send_image_file.py tests/gateway/test_telegram_documents.py -q57 passed, 12 warningsgit diff --checkI tried the full test suite, but it fails locally outside this PR due to missing optional ACP/Matrix deps and an unrelated gateway race-guard timeout.
Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
cli-config.yaml.exampleupdate is N/ACONTRIBUTING.md/AGENTS.mdupdate is N/A.pngfilesScreenshots / Logs
No screenshots or logs.