Skip to content

fix(telegram): route forwarded channel media through effective_message (#76615) - #76758

Closed
Enough1122 wants to merge 1 commit into
NousResearch:mainfrom
Enough1122:fix/76615-telegram-effective-message
Closed

fix(telegram): route forwarded channel media through effective_message (#76615)#76758
Enough1122 wants to merge 1 commit into
NousResearch:mainfrom
Enough1122:fix/76615-telegram-effective-message

Conversation

@Enough1122

Copy link
Copy Markdown
Contributor

Summary

_handle_media_message guarded on update.message and returned silently when it was None. Media forwarded from channels arrives with the real payload on update.effective_message (update.message is None), so forwarded photos/documents were never delivered to the agent — no log, no error.

Fix: resolve msg = self._effective_update_message(update) at the top (mirroring the text handler at ~line 8695) and use it for the auth / should-process / observe checks. The rest of the function already worked off a msg variable.

Also fixed the test helper to set effective_message explicitly (MagicMock would otherwise return an auto-mock, silently breaking effective-message routing).

Single-file change (plus tests). No public API change.

NOT doing X: not touching _handle_text_message (already correct), not changing download/cache flow.

Test plan

python -m pytest tests/gateway/test_telegram_documents.py -q
# 19 passed (17 existing + 2 new: forwarded channel photo + document
# arrive with update.message=None / effective_message=<msg> and are
# delivered as PHOTO/DOCUMENT events)

NousResearch#76615)

_handle_media_message guarded on update.message and exited silently when
it was None. Media forwarded from channels arrives with the payload on
update.effective_message (update.message is None), so forwarded photos
and documents were never delivered to the agent.

Mirror the text handler: resolve msg = self._effective_update_message(update)
at the top and use it for auth/should-process/observe checks.

Also set effective_message explicitly in the test helper so mocks match
python-telegram-bot semantics (a MagicMock attribute access would return
an auto-mock and silently break effective-message routing).
@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/plugins Plugin system and bundled plugins platform/telegram Telegram bot adapter sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages duplicate This issue or pull request already exists labels Aug 2, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Duplicate of #51747: both current-path patches route Telegram media through _effective_update_message() in the same adapter handler. #51747 has broader channel-post and authorization regression coverage.

@teknium1

teknium1 commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Thanks for addressing a real Telegram media-routing regression.

Problems

Suggested changes

Automated hermes-sweeper review.

@teknium1 teknium1 added sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Aug 2, 2026
@Enough1122

Copy link
Copy Markdown
Contributor Author

Duplicate of #51747 (opened 6/24, covers the same effective_message normalization for channel-post media). Closing in favor of #51747 for #76615/#51543.

@Enough1122 Enough1122 closed this Aug 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/plugins Plugin system and bundled plugins duplicate This issue or pull request already exists P3 Low — cosmetic, nice to have platform/telegram Telegram bot adapter sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants