From 2168df37b8855bddcd4e157fb19e5075d042914e Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Wed, 22 Jul 2026 08:09:52 -0700 Subject: [PATCH] fix(slack): harden parent-text wake check against None + restore fixture parity MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Follow-up rework on the #51627 cherry-pick: - Guard the 5th wake check (parent-mentioned-bot, #24848) against a None parent_text — _fetch_thread_parent_text is typed to return str but tests (and defensive callers) can surface None; 'in None' raised TypeError. - Drop the PR's fixture-level _fetch_thread_parent_text/_fetch_thread_context AsyncMocks from TestThreadReplyHandling/TestAssistantThreadLifecycle: main's #24848 tests exercise the real parent-text path via conversations_replies side effects, and the blanket mocks broke them. - _resolve_user_is_bot reworked to the workspace-scoped (team_id, user_id) cache key introduced by the multi-workspace name cache on main. --- plugins/platforms/slack/adapter.py | 2 +- tests/gateway/test_slack.py | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/plugins/platforms/slack/adapter.py b/plugins/platforms/slack/adapter.py index 36708eb28d0c..57b09273da31 100644 --- a/plugins/platforms/slack/adapter.py +++ b/plugins/platforms/slack/adapter.py @@ -4088,7 +4088,7 @@ class SlackAdapter(BasePlatformAdapter): team_id=team_id, strip_bot_mention=False, ) - if f"<@{bot_uid}>" in parent_text: + if parent_text and f"<@{bot_uid}>" in parent_text: # Remember the thread so later replies skip the fetch. if not self._slack_strict_mention(): self._register_mentioned_thread(event_thread_ts) diff --git a/tests/gateway/test_slack.py b/tests/gateway/test_slack.py index f459157e2991..4f91bcf428b1 100644 --- a/tests/gateway/test_slack.py +++ b/tests/gateway/test_slack.py @@ -4024,8 +4024,6 @@ class TestThreadReplyHandling: a._bot_user_id = "U_BOT" a._team_bot_user_ids = {"T_TEAM": "U_BOT"} a._running = True - a._fetch_thread_parent_text = AsyncMock(return_value=None) - a._fetch_thread_context = AsyncMock(return_value="") a.handle_message = AsyncMock() a.set_session_store(mock_session_store) return a @@ -4410,8 +4408,6 @@ class TestAssistantThreadLifecycle: a._bot_user_id = "U_BOT" a._team_bot_user_ids = {"T_TEAM": "U_BOT"} a._running = True - a._fetch_thread_parent_text = AsyncMock(return_value=None) - a._fetch_thread_context = AsyncMock(return_value="") a.handle_message = AsyncMock() a.set_session_store(mock_session_store) return a