Skip to content

fix: handle Telegram channel media posts - #35720

Open
nick-nikolaev wants to merge 1 commit into
NousResearch:mainfrom
nick-nikolaev:fix/telegram-channel-media-posts
Open

fix: handle Telegram channel media posts#35720
nick-nikolaev wants to merge 1 commit into
NousResearch:mainfrom
nick-nikolaev:fix/telegram-channel-media-posts

Conversation

@nick-nikolaev

Copy link
Copy Markdown

Summary

  • Use the Telegram effective message in media handling, matching the text path.
  • Fixes channel media/document posts being dropped when update.message is absent.
  • Adds regression coverage for channel media posts.

Why

Telegram channel posts arrive as update.channel_post / effective_message, not update.message. The media handler returned early before plugins could see uploaded documents.

Test Plan

  • /Users/nick/.hermes/hermes-agent/venv/bin/python -m pytest tests/gateway/test_telegram_group_gating.py -q -o 'addopts='

@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery platform/telegram Telegram bot adapter P2 Medium — degraded but workaround exists labels May 31, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #28614 — same fix: use _effective_update_message(update) instead of update.message in _handle_media_message() for channel_post media routing. Also duplicates #28813.

See also original issue #3634.

@nick-nikolaev

Copy link
Copy Markdown
Author

Thanks - yes, this overlaps with #28614 and #28813.

I opened this because the issue is still present on current main, and the older PRs appear stale/dirty against the current base. This PR is rebased on current main and includes focused regression coverage in tests/gateway/test_telegram_group_gating.py.

Happy to close this if maintainers prefer to revive one of the earlier PRs.

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review Summary

Verdict: Approved

Overview

Well-scoped fix for Telegram channel media posts being dropped. The media handler used update.message directly instead of the effective-message helper that the text path already uses. Channel posts arrive as update.channel_post / effective_message, so they were silently dropped.

Looks Good

  • Fixes a clear bug: channel media posts bypassing the entire media pipeline
  • Uses the existing _effective_update_message() helper (consistent with text path)
  • Good regression test coverage with channel post scenario
  • No observable side effects for non-channel messages

Reviewed by Hermes Agent

@nick-nikolaev
nick-nikolaev force-pushed the fix/telegram-channel-media-posts branch 3 times, most recently from 9913934 to 4f4a40c Compare June 7, 2026 07:51
@nick-nikolaev

Copy link
Copy Markdown
Author

For maintainers comparing with #28614 / #28813 / #29753:

This PR takes the same shared-handler approach — normalize with _effective_update_message(update) inside _handle_media_message() — but is rebased on current main and also keeps the observe-unmentioned branch on the normalized message object.

I intentionally avoided the older #3683-style separate channel media handler, because duplicating Telegram media caching/dispatch logic would make channel posts drift from the regular media path over time.

Scope-wise this should cover Telegram channel posts for the existing supported media/document branches, subject to the current allowlists and size limits.

@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 identifying a real Telegram channel-media gap. The underlying bug is still present on current main, but this PR no longer targets the live implementation.

Problems

  • gateway/platforms/telegram.py was renamed to plugins/platforms/telegram/adapter.py by 560010547; the current handler still returns on update.message is None at plugins/platforms/telegram/adapter.py:7764. GitHub consequently reports this PR as conflicting.
  • The live handler now also has an authorization guard at plugins/platforms/telegram/adapter.py:7766-7772; a salvage should normalize to msg before that guard and use it throughout the processing and observe branches.
  • tests/gateway/test_telegram_channel_posts.py:151-181 covers channel text and commands, not media routing.

Suggested changes

  • Port this same effective-message normalization to the bundled plugin handler and add a channel-post media regression there.

Automated hermes-sweeper review.

Telegram channel posts arrive as ``update.channel_post`` rather than
``update.message``. Use the same effective-message helper as the text
path so channel-uploaded supported files and media are cached and dispatched
instead of being dropped before plugins can see them.

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.

Current main relocated this adapter to plugins/platforms/telegram/adapter.py in 560010547; this PR therefore conflicts and this change does not reach the live handler. Salvage the normalization into the plugin handler, including its current authorization guard.

@teknium1 teknium1 added sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 13, 2026
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.

4 participants