Skip to content

fix(telegram): respect explicit private thread routing (#59453) - #59532

Merged
teknium1 merged 1 commit into
mainfrom
salvage/59453-telegram-explicit-thread
Jul 6, 2026
Merged

fix(telegram): respect explicit private thread routing (#59453)#59532
teknium1 merged 1 commit into
mainfrom
salvage/59453-telegram-explicit-thread

Conversation

@teknium1

@teknium1 teknium1 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Cron-resolved Telegram forum topics on positive chat IDs now route by message_thread_id instead of logging a false "requires a reply anchor" DM-topic failure.

Companion to #58165. Root cause: _is_private_dm_topic_send() OR'd a positive-chat-id + thread_id heuristic with the explicit telegram_dm_topic_reply_fallback flag, so cron forum-topic sends were misclassified as anchor-required DM sends.

Changes

  • plugins/platforms/telegram/adapter.py: remove _looks_like_private_chat_id() and drop the positive-chat-id heuristic from _is_private_dm_topic_send(); anchor-required path is now gated solely on explicit telegram_dm_topic_reply_fallback metadata.

Genuine DM-topic sends are unaffected — gateway/platforms/base.py::_thread_metadata_for_source always sets telegram_dm_topic_reply_fallback=True for Telegram DM-chat threaded sends (gated on chat_type=="dm"), so the fail-loud contract holds without the chat-id-sign inference.

Validation

Case Before After
cron forum topic (positive chat + thread_id, no flag) fail-loud (false failure) routes via message_thread_id
DM-topic fallback (flag set, no anchor) fail-loud fail-loud (preserved)
explicit direct_messages_topic_id routes direct, no anchor routes direct, no anchor (preserved)

Tests: 118 passed (tests/gateway/test_telegram_thread_fallback.py +3 new, test_telegram_reply_mode.py, test_delivery.py). Standalone classification E2E confirmed all four cases.

Salvaged from #59453 by @herbalizer404 (authorship preserved).

Infographic

telegram-explicit-thread-routing

@alt-glitch alt-glitch added type/bug Something isn't working 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 P2 Medium — degraded but workaround exists labels Jul 6, 2026
@teknium1
teknium1 merged commit 4a80e27 into main Jul 6, 2026
31 checks passed
@teknium1
teknium1 deleted the salvage/59453-telegram-explicit-thread branch July 6, 2026 10:18
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 P2 Medium — degraded but workaround exists platform/telegram Telegram bot adapter 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