mastra-ai/mastra · error · HTTPException
Channel "${platform}" does not support programmatic disconne
Error message
Channel "${platform}" does not support programmatic disconnection What it means
The disconnect-channel handler throws HTTP 400 when the channel instance resolved for the requested platform does not implement a `disconnect` method. Symmetric to connect: channels whose lifecycle is managed externally cannot be programmatically disconnected through this API.
Source
Thrown at packages/server/src/server/handlers/channels.ts:217
* POST /channels/:platform/:agentId/disconnect - Disconnect an agent from a platform
*/
export const DISCONNECT_CHANNEL_ROUTE = createRoute({
method: 'POST',
path: '/channels/:platform/:agentId/disconnect',
responseType: 'json',
pathParamSchema: channelAgentPathParams,
responseSchema: disconnectChannelResponseSchema,
summary: 'Disconnect agent from channel',
description: 'Deletes the platform app and cleans up the installation',
tags: ['Channels'],
requiresAuth: true,
handler: async ({ mastra, requestContext, platform, agentId }) => {
assertChannelsAvailable();
try {
const channel = getChannelOrThrow(mastra, platform);
if (!channel.disconnect) {
throw new HTTPException(400, {
message: `Channel "${platform}" does not support programmatic disconnection`,
});
}
await assertChannelAgentWriteAccess(mastra, requestContext, agentId, 'disconnect');
await channel.disconnect(agentId);
return { success: true };
} catch (error) {
return handleError(error, 'Error disconnecting agent from channel');
}
},
});
View on GitHub (pinned to 75dd419e61)
Solutions
- Only call disconnect for platforms whose channel implements disconnect(); remove externally-managed channels via their own console
- Implement or register a channel subclass that supports programmatic disconnection
- Check channel capabilities first and skip platforms without disconnect support
- If disconnect support should exist, upgrade the channel/core package to a version that implements it
Example fix
// before
for (const p of ['slack', 'sms']) await client.disconnectChannel({ platform: p, agentId });
// after
for (const p of ['slack', 'sms']) {
const ch = channels.find(c => c.platform === p);
if (ch?.supportsDisconnect) await client.disconnectChannel({ platform: p, agentId });
} Defensive patterns
Strategy: validation
Validate before calling
const channel = channels.find(c => c.platform === platform);
if (!channel?.supportsDisconnect) throw new Error(`Platform ${platform} does not support programmatic disconnect`); Type guard
function supportsDisconnect(ch: { disconnect?: unknown } | undefined): ch is { disconnect: Function } {
return !!ch && typeof ch.disconnect === 'function';
} Try / catch
try {
await client.disconnectChannel({ platform, agentId });
} catch (e) {
if (e.status === 400 && /does not support programmatic disconnection/.test(e.message)) {
return { disconnected: false, reason: 'manual-setup-required' };
}
throw e;
} Prevention
- Check disconnect capability before bulk teardown scripts
- Handle externally-managed channels via their own console
- Re-verify capabilities after channel package upgrades
- Fail soft in cleanup jobs when a platform lacks disconnect
When it happens
Trigger: POSTing to the channel disconnect route with a platform whose registered channel lacks `channel.disconnect`, i.e. the integration has no programmatic teardown method, even though the channel is registered.
Common situations: Disconnecting a channel that was bound via external dashboard configuration; scripts that loop over all connected platforms and call disconnect on each, hitting a platform without disconnect support; channel implementation changes removing disconnect in an upgrade.
Related errors
- Channel "${platform}" does not support programmatic connecti
- Workflow ID is required
- perPage must be a positive integer
- page must be a non-negative integer
- Run ID is required
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/18ed7117c146953a.
Report an issue: GitHub.