Skip to content

fix(telegram): handle channel_post media via effective_message - #28614

Open
soynchux wants to merge 1 commit into
NousResearch:mainfrom
soynchux:fix/telegram-channel-post-media-handling
Open

fix(telegram): handle channel_post media via effective_message#28614
soynchux wants to merge 1 commit into
NousResearch:mainfrom
soynchux:fix/telegram-channel-post-media-handling

Conversation

@soynchux

Copy link
Copy Markdown
Contributor

Summary

Fix Telegram channel_post media handling so channel photo/media posts are routed through the same effective_message path already used by text and command updates.

Previously _handle_media_message() read from update.message, which is None for Update.channel_post, causing channel media posts to be silently ignored.

Changes

  • switch Telegram media handling to use effective_message
  • add a regression test covering photo delivery from Update.channel_post

Test

  • pytest tests/gateway/test_telegram_channel_posts.py -q

Result:

  • 4 passed in 5.79s

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

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the focused Telegram fix. I checked this against current origin/main (29c6985590043fc672a6c9a7cdb9a8695388d1ac), and the premise still holds.

Problems

  • Current main still returns early in gateway/platforms/telegram.py:5995 when update.message is absent, so Telegram channel_post media can be dropped before a MessageEvent is built.
  • The media handler has gained an observed-unmentioned-group branch on current main at gateway/platforms/telegram.py:5997-6007; when this is salvaged, that branch also needs to use the normalized msg, not update.message.

Suggested changes

  • Apply the same _effective_update_message(update) normalization throughout _handle_media_message(): the early guard, _should_process_message, the observe branch, and the final media-processing path.
  • Keep the added regression test from tests/gateway/test_telegram_channel_posts.py; it covers the right behavior for channel-post photo delivery.

Automated hermes-sweeper review; humans decide final salvage/merge.

if not msg:
return
if not self._should_process_message(update.message):
if not self._should_process_message(msg):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When this is salvaged onto current main, carry this normalized msg through the current observed-unmentioned-group branch too; that branch now still reads update.message, which is also None for channel_post updates.

@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the focused Telegram regression fix. The underlying issue still exists on current main, but the adapter was subsequently moved and gained additional intake guards.

Problems

  • plugins/platforms/telegram/adapter.py:7764 still returns when update.message is absent. This conflicts with the channel-post contract documented by _effective_update_message() at plugins/platforms/telegram/adapter.py:7493-7501.
  • The current handler also reads update.message throughout authorization and unmentioned-group observation (plugins/platforms/telegram/adapter.py:7766-7783). Porting only the original diff would leave those current paths dereferencing the absent field.

Suggested changes

  • Resolve the effective message once at the beginning of _handle_media_message() and consistently use it throughout every guard and media path.
  • Recreate the added channel-photo regression against the current plugin import in tests/gateway/test_telegram_channel_posts.py.

Automated hermes-sweeper review; humans decide final salvage/merge.

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 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 type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants