From 565ea19a491c7164d09a135cf33262a17bce44f5 Mon Sep 17 00:00:00 2001 From: ygd58 Date: Thu, 23 Jul 2026 08:07:09 -0700 Subject: [PATCH] test(slack): pin catch-all event matcher registration and non-shadowing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Regression test for the catch-all ack: a re.compile(r'.*') event matcher must be registered (after every named handler, so it never shadows message/app_mention/reaction/file routing) and must match unhandled subscribed event types like member_joined_channel / channel_archive / pin_added. Salvaged from #64218 (test half only — its adapter-side catch-all is a duplicate of #38847, which landed as the base commit of this cluster with first-submitter credit). Fixes #6572. Co-authored-by: shivasymbl --- tests/gateway/test_slack.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/gateway/test_slack.py b/tests/gateway/test_slack.py index 4b43d9d54604..e5a776cf63d2 100644 --- a/tests/gateway/test_slack.py +++ b/tests/gateway/test_slack.py @@ -346,6 +346,26 @@ class TestAppMentionHandler: expected ), f"Slack slash regex does not match {expected}" + # Catch-all generic matcher must be registered after the named handlers + # so it does not shadow them. It fires for any event type not already + # claimed by a named handler (issue #6572). + import re as _re2 + catchall_patterns = [e for e in registered_events if isinstance(e, _re2.Pattern)] + assert catchall_patterns, ( + "A catch-all re.compile(r'.*') event matcher must be registered to " + "silence Bolt WARNING+404 for unhandled subscribed event types. " + f"Registered events: {registered_events!r}" + ) + catchall = catchall_patterns[-1] + # Must match event types that have no named handler. + for unsupported_type in ("member_joined_channel", "channel_archive", "pin_added"): + assert catchall.match(unsupported_type), ( + f"Catch-all matcher must match {unsupported_type!r}" + ) + # Must also match the named types (the named handlers are registered + # first so they take priority; the catch-all is a safety net only). + assert catchall.match("message") + @pytest.mark.asyncio async def test_connect_uses_profile_scoped_app_token(self): """Socket Mode must use the active profile's app token in multiplex mode."""