Skip to content

fix(slack): support namespaced slash commands + robust multi-app app_id filtering#23326

Open
sebuh-infsol wants to merge 3 commits intoNousResearch:mainfrom
sebuh-infsol:fix/slack-multi-app-filtering
Open

fix(slack): support namespaced slash commands + robust multi-app app_id filtering#23326
sebuh-infsol wants to merge 3 commits intoNousResearch:mainfrom
sebuh-infsol:fix/slack-multi-app-filtering

Conversation

@sebuh-infsol
Copy link
Copy Markdown

@sebuh-infsol sebuh-infsol commented May 10, 2026

Summary

This fixes Slack multi-app slash-command routing issues that caused cross-app handling and timeouts for app-prefixed slash commands.

Changes

  • Resolve Slack app_id via apps.connections.open using the app token instead of relying on auth.test (which may omit app_id).
  • Keep per-app filtering in _handle_slash_command using api_app_id against resolved self._app_ids.
  • Broaden Bolt slash command matcher from native-command whitelist to a valid slash-token regex (^/[a-z0-9_-]{1,64}$) so manifest-prefixed commands (e.g. /khelp, /kimberly) are acked and dispatched.
  • Add routing support for prefixed command sets:
    • Treat /kimberly as legacy single-entry alias (same behavior as /hermes).
    • For unknown slash names starting with k, strip one leading k if the stripped name resolves to a known command (/khelp -> /help, /kcommands -> /commands).
  • Add temporary route debug logging in slash handler to validate live routing behavior.

Why

  • In Socket Mode, Slack delivers command events to connected apps; without robust app filtering and slash matcher coverage, one app can process another app's commands or fail to ack prefixed commands, causing Slack timeouts.

Validation

  • python3 -m py_compile gateway/platforms/slack.py
  • Live log verification (local):
    • /khelp -> /help
    • /kcommands -> /commands
    • /kimberly -> /help
    • Responses were sent (no timeout in validated cycle).

Notes

  • Debug route logging can be downgraded/removed after confirmation in production-like environments.

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
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery platform/slack Slack app adapter labels May 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists platform/slack Slack app adapter type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants