Skip to content

fix: correct channel allowlist/blocklist logic in isChannelAllowedForConfig#189

Merged
korotovsky merged 1 commit intokorotovsky:masterfrom
RedSlowpoke:fix/channel-allowlist-logic
Feb 6, 2026
Merged

fix: correct channel allowlist/blocklist logic in isChannelAllowedForConfig#189
korotovsky merged 1 commit intokorotovsky:masterfrom
RedSlowpoke:fix/channel-allowlist-logic

Conversation

@RedSlowpoke
Copy link

Summary

  • Fixed inverted return logic in isChannelAllowedForConfig()
  • Allowlist mode now correctly blocks channels NOT in the list
  • Blocklist mode now correctly allows channels NOT in the list

Resolves #138

Expected Behavior (per README)

From README.md, Environment Variables section:

SLACK_MCP_ADD_MESSAGE_TOOL - Enable message posting... by setting it to a comma-separated list of channel IDs to whitelist specific channels, or use ! before a channel ID to allow all except specified ones

This means:

  • C123,C456 (allowlist) → only C123 and C456 are allowed, others blocked
  • !C123,!C456 (blocklist) → all channels allowed except C123 and C456

Root Cause

Line 620 returned !isNegated instead of isNegated when no match was found in the channel list, inverting the intended behavior.

Changes

  • Fixed return statement in pkg/handler/conversations.go:620
  • Added unit tests for isChannelAllowedForConfig()

Test plan

  • Added 16 unit tests covering allowlist, blocklist, and edge cases
  • All existing tests pass

The isChannelAllowedForConfig() function had inverted return logic.
When a channel was NOT found in the list, it returned the opposite
of what was intended:
- Allowlist mode incorrectly allowed unlisted channels
- Blocklist mode incorrectly blocked unlisted channels

Fixed by changing 'return !isNegated' to 'return isNegated'.
Added unit tests for isChannelAllowedForConfig().

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@korotovsky korotovsky merged commit 52bbb09 into korotovsky:master Feb 6, 2026
2 checks passed
@RedSlowpoke RedSlowpoke deleted the fix/channel-allowlist-logic branch February 8, 2026 22:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Setting SLACK_MCP_ADD_MESSAGE_TOOL environment variable to comma separated string still allows messages to be sent to all channels

2 participants