fix(gateway): preserve new Telegram DM topic lanes#31444
Merged
Conversation
Contributor
🔎 Lint report:
|
| Rule | Count |
|---|---|
unresolved-attribute |
1 |
invalid-argument-type |
1 |
First entries
tests/gateway/test_telegram_thread_fallback.py:101: [unresolved-attribute] unresolved-attribute: Unresolved attribute `TypeHandler` on type `ModuleType`
tests/gateway/test_telegram_topic_mode.py:1229: [invalid-argument-type] invalid-argument-type: Argument to bound method `SessionDB.bind_telegram_topic` is incorrect: Expected `str`, found `str | None`
✅ Fixed issues: none
Unchanged: 4840 pre-existing issues carried over.
Diagnostics are surfaced as warnings — this check never fails the build.
The cherry-picked fix from #28605 inverts an existing test (an unknown non-lobby thread_id no longer rewrites to the most-recent binding), but that test only seeds two bindings and queries a third thread_id. Add a second regression test that more closely mirrors the live failure mode: seed exactly one prior binding, then query a brand-new thread_id and assert recovery returns None — so the new topic is allowed to get its own session row instead of being silently merged into the previous topic's session. Co-authored-by: Fábio Siqueira <fabioxxx@gmail.com> Co-authored-by: dillweed <dillweed@users.noreply.github.com>
ff6e6f1 to
148e2b8
Compare
This was referenced May 24, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Brand-new Telegram DM topics no longer get hijacked into the previous topic's session.
_recover_telegram_topic_thread_idnow only rewrites lobby/General thread_ids (preserving the #3206 strip recovery); any explicit, non-lobby thread_id is trusted as-is so a freshly-created topic can be recorded as its own lane.Root cause (#31086): the recovery function ran before
_record_telegram_topic_binding, and its "unknown non-lobby thread_id -> snap to most-recent" arm matched every new topic. The hijack was self-reinforcing because the new topic's binding row was never written, so every subsequent message looked unknown and was hijacked again.Changes
gateway/run.py: drop theinbound in knownshort-circuit; non-lobby thread_ids return None unconditionally. Docstring rewritten.tests/gateway/test_telegram_topic_mode.py: invert the existingtest_recover_rewrites_unknown_thread_id_to_most_recent->test_recover_preserves_unknown_thread_id_for_new_topic, plus a newtest_recover_returns_none_for_brand_new_topicregression that mirrors the live failure mode (one prior binding + a brand-new thread_id).tests/gateway/test_telegram_thread_fallback.py: stub_fake_telegram_ext.TypeHandlerso the shared fake module covers all handler classes the real telegram-ext exposes.Validation
tests/gateway/test_telegram_topic_mode.pytests/gateway/test_telegram_thread_fallback.pytests/gateway/(full suite)Credit
Closes #31086.
Supersedes #28605, #29287, #29546, #30422, #31088.
Infographic