-
Notifications
You must be signed in to change notification settings - Fork 10.9k
fix(channels): keep empty topic_id distinct from missing topic #4723
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -289,6 +289,23 @@ def test_corrupt_file_handled(self, tmp_path): | |
| store = ChannelStore(path=path) | ||
| assert store.get_thread_id("x", "y") is None | ||
|
|
||
| def test_empty_topic_id_is_distinct_from_none(self, store): | ||
| """Empty topic_id must not collapse onto the topic-less base key. | ||
|
|
||
| Channels such as DingTalk may pass ``topic_id=""`` when a group | ||
| message lacks ``message_id``. Truthy keying would overwrite/delete the | ||
| base conversation mapping instead of a topic-specific entry. | ||
| """ | ||
| store.set_thread_id("dingtalk", "conv", "base-thread", topic_id=None) | ||
| store.set_thread_id("dingtalk", "conv", "empty-topic-thread", topic_id="") | ||
|
|
||
| assert store.get_thread_id("dingtalk", "conv") == "base-thread" | ||
| assert store.get_thread_id("dingtalk", "conv", topic_id="") == "empty-topic-thread" | ||
|
|
||
| assert store.remove("dingtalk", "conv", topic_id="") is True | ||
| assert store.get_thread_id("dingtalk", "conv", topic_id="") is None | ||
| assert store.get_thread_id("dingtalk", "conv") == "base-thread" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice targeted regression test. Small gap worth closing: nothing here (or in |
||
|
|
||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # Channel base class tests | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct fix. One thing worth a follow-up: the upstream source of empty
topic_idvalues is still live indingtalk.py, wheremsg_id = message.message_id or ""feedstopic_id = msg_id if GROUP else None. With this change those group messages no longer clobber the base key (good), but everymessage_id-less group message in the same conversation now buckets into one shared thread atchannel:conv:. If the intended DingTalk group semantics is one-thread-per-message, that's still broken upstream whenevermessage_idis missing — normalizingmsg_id or Nonewould make empty genuinely topic-less. Out of scope for this PR, but worth filing so the upstream source of""isn't forgotten.