From 7e42f0143c5eed1e0708afd388b4eaff5f4042de 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 1a03c2b57f22..90fbcdc7da38 100644 --- a/plugins/platforms/slack/adapter.py +++ b/plugins/platforms/slack/adapter.py @@ -3820,7 +3820,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 cd121c313abf..ac67760f41c3 100644 --- a/tests/gateway/test_slack.py +++ b/tests/gateway/test_slack.py @@ -3538,8 +3538,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 @@ -3924,8 +3922,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