#14795: fix: skip disabled channel plugins in cross-context messaging checks
stale
size: S
Cluster:
Network Error Handling Improvements
## Problem
Fixes #14769
The `message` tool reports `Cross-context messaging denied: action=send target provider "telegram" while bound to "whatsapp"` even when the WhatsApp plugin is `enabled: false` in config. This prevents agents from sending messages to Telegram from sessions that have a stale whatsapp binding.
## Root Cause
`resolveGatewayMessageChannel` and `normalizeMessageChannel` in `src/utils/message-channel.ts` did not check whether a channel's plugin was actually enabled. A disabled plugin (e.g. whatsapp with `enabled: false`) was still resolved as a valid channel, causing the cross-context check to bind the session to a non-functional channel.
## Fix
- Added `isDisabledPluginChannel()` helper that checks the plugin registry for disabled status
- `normalizeMessageChannel()` now returns `undefined` for disabled channel plugins
- Added `isGatewayMessageChannelEnabled()` check in `resolveGatewayMessageChannel()`
Three layers of defense ensure disabled plugins are never considered for channel binding.
## Tests
- Added regression test in `src/utils/message-channel.test.ts` that creates a disabled whatsapp plugin record and asserts `resolveGatewayMessageChannel("whatsapp")` returns `undefined`
- Test fails on `main` (confirms it catches the bug), passes with the fix
- All existing message-channel tests continue to pass
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR adds a disabled-plugin guard when resolving gateway message channels (`resolveGatewayMessageChannel`) by consulting the active plugin registry’s `plugins` list and rejecting channels whose corresponding `PluginRecord.enabled` is `false`. It also adds a unit test intended to prevent binding sessions to disabled channel plugins.
The main issue is that the new regression test doesn’t currently exercise the bug scenario: with `registry.channels` empty, `"whatsapp"` isn’t considered a valid gateway/deliverable channel at all, so `resolveGatewayMessageChannel("whatsapp")` returns `undefined` regardless of the new enabled-check. The test should include a `registry.channels` entry for the whatsapp channel while marking the plugin record disabled, so it would fail on `main` and pass with this change.
<h3>Confidence Score: 3/5</h3>
- This PR is likely safe, but the added test does not currently validate the intended regression scenario.
- The runtime change is small and scoped to gateway-channel resolution, but the accompanying test would pass even without the fix because the registry setup doesn’t make the disabled plugin a valid deliverable/gateway channel. Fixing the test to cover the real scenario would increase confidence.
- src/utils/message-channel.test.ts
<!-- greptile_other_comments_section -->
<sub>(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#23727: Fix Telegram channel resolution drift across announce + message sen...
by SmithLabsLLC · 2026-02-22
80.5%
#18966: fix(config): downgrade unknown bundled plugin references to warnings
by moxunjinmu · 2026-02-17
78.1%
#22469: fix(gateway): avoid stale whatsapp labels on direct sessions
by loganprit · 2026-02-21
78.0%
#12870: fix: recover from telegram fetch errors (issue #12835)
by ambicuity · 2026-02-09
77.9%
#23148: fix: forward mediaLocalRoots in whatsapp plugin sendMedia
by MunemHashmi · 2026-02-22
77.5%
#9006: fix: streaming UI, session locks, routing performance, plugin sandb...
by facundollamas2007 · 2026-02-04
77.1%
#16830: fix: session lookup default
by Limitless2023 · 2026-02-15
77.1%
#7353: fix: prevent silent message drops after config.patch restart
by 18-RAJAT · 2026-02-02
76.4%
#13881: fix: Address Greptile feedback - test isolation and channel resolution
by trevorgordon981 · 2026-02-11
76.3%
#9268: Fix: Register feishu as official channel in CHAT_CHANNEL_ORDER
by vishaltandale00 · 2026-02-05
76.3%