fix(gateway): fail Telegram document sends on invalid files#13933
Open
conan0220 wants to merge 1 commit into
Open
fix(gateway): fail Telegram document sends on invalid files#13933conan0220 wants to merge 1 commit into
conan0220 wants to merge 1 commit into
Conversation
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?
This PR fixes a Telegram document delivery bug where Hermes could fall back to sending plain text like
📎 File: /instead of a real attachment.Previously, if
TelegramAdapter.send_document()received a path that existed but was not a regular file (for example/), the upload path would raise an exception and fall back to the base adapter's text-only document sender. That made delivery look successful even though no actual file was sent.This change fixes that by:
This is the right approach because it preserves correctness: a failed document upload should fail explicitly rather than pretending success with a text fallback.
After this fix, Hermes can successfully send real document attachments through Telegram when given a valid file path, and it now fails explicitly instead of falling back to misleading plain-text file path messages.
Related Issue
Fixes #13356
Type of Change
Changes Made
gateway/platforms/telegram.py_invalid_media_path_error(...)os.path.isfile(...)validation before Telegram document uploadSendResult(success=False, ...)print(...)fallback behavior with structured logging vialogger.error(...)tests/gateway/test_telegram_documents.pyHow to Test
python -m pytest tests/gateway/test_telegram_documents.py -q -o 'addopts='send_document()with/or another directory path and confirm it returns a real failure such as:Checklist
Code
fix(scope):, feat(scope):, etc.)Documentation & Housekeeping
Screenshots / Logs
Test command:
python -m pytest tests/gateway/test_telegram_documents.py -q -o 'addopts='Result:
Manual verification:
/now returns:📎 File: /is no longer used for this failure case