Skip to content

fix(telegram): resolve channel_post media updates via effective message normalization - #29753

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

fix(telegram): resolve channel_post media updates via effective message normalization#29753
Sylw3ster wants to merge 1 commit into
NousResearch:mainfrom
Sylw3ster:fix/telegram-channel-post-media-handling

Conversation

@Sylw3ster

Copy link
Copy Markdown
Contributor

What does this PR do?

This PR fixes a missed Telegram channel_post code path for media messages.

In Telegram, channel broadcasts arrive as Update.channel_post rather than Update.message. PR 704872a62 introduced _effective_update_message() and updated the text/command/location handlers to use it, but _handle_media_message() was still reading update.message directly. As a result, channel-post media updates (for example stickers, photos, videos, audio, voice notes, and documents) could be silently ignored before a MessageEvent was ever built.

The fix keeps the existing behavior and simply aligns the media handler with the same invariant already established for the sibling handlers: normalize the incoming update through effective_message first, then process it normally. This is the smallest behavior-preserving fix and directly addresses the broken path without changing unrelated Telegram media logic.

Related Issue

Fixes #

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • Updated gateway/platforms/telegram.py so _handle_media_message() uses _effective_update_message(update) instead of reading update.message directly.
  • Updated the "observe unmentioned group message" branch inside the same media handler to use the normalized message object consistently.
  • Added a regression test in tests/gateway/test_telegram_channel_posts.py covering a channel_post media message and asserting it is routed through the media handler instead of being dropped.

How to Test

  1. Reproduce the old behavior by sending a Telegram channel media post (for example a sticker) to the bot path that reaches _handle_media_message(). Before this fix, the handler could return early because update.message is None for channel_post updates.
  2. Run the regression test:
    • Linux/macOS/CI: scripts/run_tests.sh tests/gateway/test_telegram_channel_posts.py -q
    • Windows local override: uv run --extra dev pytest tests/gateway/test_telegram_channel_posts.py -q -n 0 --timeout-method=thread
  3. Confirm the channel-post media test passes and that channel-post text/command coverage still passes alongside it.

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)

Screenshots / Logs

Local targeted verification passed:

uv run --extra dev pytest tests/gateway/test_telegram_channel_posts.py -q -n 0 --timeout-method=thread
....                                                                     [100%]
4 passed in 1.51s

@Sylw3ster Sylw3ster changed the title fix(telegram): resolve channel_post media updates via effective messa… fix(telegram): resolve channel_post media updates via effective message normalization May 21, 2026
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists platform/telegram Telegram bot adapter comp/gateway Gateway runner, session dispatch, delivery labels May 21, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #28614 — same fix applying _effective_update_message() to _handle_media_message() for channel_post media routing. Also see #28813 for the same approach.

@Sylw3ster

Copy link
Copy Markdown
Contributor Author

dublicate

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.

2 participants