You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Preserve Telegram DM topic routing metadata in synthetic gateway notifications.
This change fixes a routing gap where synthetic notifications such as /update, /restart, and startup home-channel messages could bypass the shared Telegram DM topic metadata path and send with only thread_id. For Telegram DM topic lanes, that could route notifications outside the intended topic.
What Changed
Centralized synthetic thread metadata generation through the same helper logic used by normal thread-aware replies.
Preserved chat_type in update and restart marker payloads so post-restart notification paths can reconstruct Telegram DM topic routing correctly.
Added Telegram DM topic fallback metadata for synthetic sends when the target is a DM topic:
telegram_dm_topic_reply_fallback
direct_messages_topic_id
Kept home-channel startup notifications on the same metadata path so configured Telegram DM topic homes stay correctly routed.
Tightened regression coverage to assert the full Telegram DM topic metadata, not just thread_id.
Merged via #36028 — your commit was cherry-picked onto current main with authorship preserved (it was ~320 commits behind, so a salvage was cleaner than rebasing the branch).
This also fixes the /restart + home-channel "Telegram DM topic delivery requires a reply anchor; refusing to send outside the requested topic" failure: the direct_messages_topic_id metadata you added lets _is_private_dm_topic_send route the notification through the anchorless DM-topic path, so no reply anchor is needed.
I added one small follow-up on top: _is_telegram_dm_topic_target now resolves _get_dm_topic_info on the adapter class (type(adapter)) and treats only dict-shaped returns as a declared topic — instance-level getattr was a false positive for MagicMock test doubles. Mirrors the existing guard in _rename_telegram_topic_for_session_title.
Thanks for the fix! 🙏
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
comp/gatewayGateway runner, session dispatch, deliveryP2Medium — degraded but workaround existsplatform/telegramTelegram bot adaptertype/bugSomething isn't working
3 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Preserve Telegram DM topic routing metadata in synthetic gateway notifications.
This change fixes a routing gap where synthetic notifications such as
/update,/restart, and startup home-channel messages could bypass the shared Telegram DM topic metadata path and send with onlythread_id. For Telegram DM topic lanes, that could route notifications outside the intended topic.What Changed
chat_typein update and restart marker payloads so post-restart notification paths can reconstruct Telegram DM topic routing correctly.telegram_dm_topic_reply_fallbackdirect_messages_topic_idthread_id.Testing
Focused regression verification:
tests/gateway/test_update_command.py::TestHandleUpdateCommand::test_writes_pending_marker— passedtests/gateway/test_update_command.py::TestHandleUpdateCommand::test_writes_pending_marker_with_thread_id— passedtests/gateway/test_update_command.py::TestSendUpdateNotification::test_sends_notification_with_thread_metadata— passedtests/gateway/test_update_command.py::TestSendUpdateNotification::test_defers_notification_while_update_still_running— passedtests/gateway/test_update_command.py::TestSendUpdateNotification::test_sends_generic_message_when_no_output— passedtests/gateway/test_restart_notification.py::test_restart_command_writes_notify_file— passedtests/gateway/test_restart_notification.py::test_restart_command_preserves_thread_id— passedtests/gateway/test_restart_notification.py::test_send_home_channel_startup_notification_preserves_thread_metadata— passedtests/gateway/test_restart_notification.py::test_send_restart_notification_with_thread— passedtests/gateway/test_restart_notification.py::test_shutdown_notifications_use_cached_live_thread_source_when_origin_missing— passedFocused regression result:
Broader targeted suite command:
Broader targeted suite result:
Remaining failures from the broader targeted suite:
tests/gateway/test_update_command.py::TestHandleUpdateCommand::test_spawns_setsidtests/gateway/test_update_command.py::TestHandleUpdateCommand::test_fallback_when_no_setsidtests/gateway/test_update_command.py::TestSendUpdateNotification::test_sends_notification_with_outputtests/gateway/test_update_command.py::TestSendUpdateNotification::test_strips_ansi_codestests/gateway/test_update_command.py::TestSendUpdateNotification::test_cleans_up_files_after_notificationtests/gateway/test_update_command.py::TestSendUpdateNotification::test_cleans_up_on_errorNotes
The scoped regression coverage for this fix is green. The remaining failures are outside the routing change itself and should be handled separately.