fix(slack): support namespaced slash commands + robust multi-app app_id filtering#23326
Open
sebuh-infsol wants to merge 3 commits intoNousResearch:mainfrom
Open
fix(slack): support namespaced slash commands + robust multi-app app_id filtering#23326sebuh-infsol wants to merge 3 commits intoNousResearch:mainfrom
sebuh-infsol wants to merge 3 commits intoNousResearch:mainfrom
Conversation
In Socket Mode, Slack sends ALL events to ALL connected apps. This causes both Kimberly and Derp to receive each other's slash commands, resulting in commands being processed by the wrong bot. Fix: Extract app_id from auth_test() response during connect(), collect all configured app_ids into a set, and filter incoming slash commands by api_app_id so each gateway only processes commands intended for its own app. - Add self._app_ids: set in __init__ - Extract app_id from auth_test() in connect() - Filter slash commands in _handle_slash_command() by api_app_id
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
This fixes Slack multi-app slash-command routing issues that caused cross-app handling and timeouts for app-prefixed slash commands.
Changes
app_idviaapps.connections.openusing the app token instead of relying onauth.test(which may omitapp_id)._handle_slash_commandusingapi_app_idagainst resolvedself._app_ids.^/[a-z0-9_-]{1,64}$) so manifest-prefixed commands (e.g./khelp,/kimberly) are acked and dispatched./kimberlyas legacy single-entry alias (same behavior as/hermes).k, strip one leadingkif the stripped name resolves to a known command (/khelp -> /help,/kcommands -> /commands).Why
Validation
python3 -m py_compile gateway/platforms/slack.py/khelp -> /help/kcommands -> /commands/kimberly -> /helpNotes