fix(cron): use message_thread_id for private-chat forum topics (#55265) - #55270
fix(cron): use message_thread_id for private-chat forum topics (#55265)#55270nniicckk6 wants to merge 1 commit into
Conversation
…esearch#55265) PR NousResearch#50023 blanket-switched all private-chat cron deliveries to use direct_messages_topic_id instead of message_thread_id. This silently broke forum-style topics in private chats (created via createForumTopic), because Telegram accepts direct_messages_topic_id with ok: true but silently renders the message in General instead of the topic. The Bot API 10.0 server-side regression (NousResearch#22022) that motivated the switch was fixed by Telegram on May 9, 2026 — message_thread_id works for all private-chat topic types again. Fix: route via message_thread_id (the default path). The adapter's existing thread-not-found fallback already retries with direct_messages_topic_id for native DM-topics mode if needed. Closes NousResearch#55265 Relates to NousResearch#22773, NousResearch#22022
Competing fix with #52079 for the same bug (forum topics in private chats mis-routed to General via the cron |
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: LGTM
Fixes cron topic routing for private-chat forum topics. Uses message_thread_id directly instead of the overly-broad blanket switch from PR #50023.
- Clean simplification of topic routing logic
- Fixes regression from prior PR
- Well-scoped: 1 file, 28 additions
Reviewed 1 file, 28 additions. Approved.
|
Thanks for the focused diagnosis. This is already fixed on current
This also addresses the member comment identifying the competing approaches: main retained the forum-topic fix while avoiding regression for genuine channel DM topics. |
Problem
PR #50023 blanket-switched all Telegram private-chat cron deliveries from
message_thread_idtodirect_messages_topic_id. This silently broke forum-style topics in private chats (created viacreateForumTopicAPI), because Telegram acceptsdirect_messages_topic_idwithok: truebut renders the message in General instead of the requested topic — no error, no retry, silent failure.Full details in #55265.
Root Cause
There are two distinct private-chat topic topologies:
message_thread_iddirect_messages_topic_idcreateForumTopicAPIThe Bot API 10.0 regression (#22022) that originally broke
message_thread_idwas fixed by Telegram server-side on May 9, 2026. Both parameters now work for both topologies — exceptdirect_messages_topic_idis silently ignored for forum topics.cron/scheduler.py:1251-1266could not distinguish between the topologies and used the parameter wrong for the more common case (forum topics).Fix
Remove the
is_private_dm_topicbranch that setdirect_messages_topic_id. Route throughmessage_thread_id(the default path for all other targets). The adapter's existing thread-not-found fallback (plugins/platforms/telegram/adapter.py) already retries withdirect_messages_topic_idif Telegram returns400 thread not found— so native DM-topics mode is still covered.Evidence
User confirmed via Telegram client:
message_thread_idappears in the correct topic,direct_messages_topic_idappears in General.Why not detect the topology?
getChatdoes not returnis_forum: truefor private chats with forum topics (the field is absent). There is no reliable Bot API to distinguish the two topologies at send time. Usingmessage_thread_idfirst with adirect_messages_topic_idfallback is the robust approach — matching how the gateway adapter already works.Testing
python3 -m py_compile cron/scheduler.py✅Related