different-ai/openwork · error
Disconnect MCP connection response was incomplete.
Error message
Disconnect MCP connection response was incomplete.
What it means
The disconnect MCP connection mutation assigns `result = connectionId` inside runReauthableAction after a successful disconnect fetch. If the callback never assigned (re-auth resolved without executing, or connectionId was falsy) this guard throws so the mutation can't resolve with undefined.
Source
Thrown at ee/apps/den-web/app/(den)/dashboard/_components/mcp-connections-data.tsx:945
export function useDisconnectMcpConnection() {
const queryClient = useQueryClient();
const { orgId, runReauthableAction } = useOrgDashboard();
return useMutation({
mutationFn: async (connectionId: string): Promise<string> => {
let result: string | null = null;
await runReauthableAction("disconnect-mcp-connection", async () => {
const { response, payload } = await requestJson(
`/v1/mcp-connections/${encodeURIComponent(connectionId)}/disconnect`,
{ method: "POST", headers: getOrgScopeHeaders(requireOrgId(orgId)) },
15000,
);
if (!response.ok) {
throw getRequestError(payload, response, `Failed to disconnect MCP connection (${response.status}).`);
}
result = connectionId;
});
if (!result) throw new Error("Disconnect MCP connection response was incomplete.");
return result;
},
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: mcpConnectionQueryKeys.all });
},
});
}
export function useDeleteMcpConnection() {
const queryClient = useQueryClient();
const { orgId, runReauthableAction } = useOrgDashboard();
return useMutation({
mutationFn: async (connectionId: string): Promise<string> => {
let result: string | null = null;
await runReauthableAction("delete-mcp-connection", async () => {
const { response, payload } = await requestJson(
`/v1/mcp-connections/${encodeURIComponent(connectionId)}`,View on GitHub (pinned to 2b7df46e8a)
Solutions
- Ensure connectionId is a non-empty string before mutating
- Verify runReauthableAction throws on dismissed re-auth rather than resolving undefined
- Log inside the callback to confirm the disconnect fetch and assignment execute
- Note the disconnect endpoint may return 2xx with empty body — the guard only checks the local variable, so confirm the callback reached `result = connectionId`
Example fix
// before
if (!result) throw new Error("Disconnect MCP connection response was incomplete.");
// after
if (!result) {
throw new Error(`Disconnect MCP connection: no connectionId assigned (input=${JSON.stringify(connectionId)}).`);
} Defensive patterns
Strategy: validation
Validate before calling
if (typeof connectionId !== 'string' || connectionId.length === 0) {
throw new Error('cannot disconnect: connectionId missing');
} Type guard
function isDisconnectInput(v: unknown): v is { connectionId: string } {
return isRecord(v) && typeof v.connectionId === 'string' && v.connectionId.length > 0;
} Try / catch
try {
await disconnect.mutateAsync(connectionId);
} catch (e) {
showToast({ variant: 'error', title: 'Disconnect failed', description: e instanceof Error ? e.message : String(e) });
queryClient.invalidateQueries({ queryKey: mcpConnectionQueryKeys.all });
} Prevention
- Guard disconnect buttons against stale/already-removed rows
- Invalidate the list on error to reconcile UI with server state
- Keep the reauth wrapper throwing on dismissal
- Add an API test that the disconnect endpoint responds 2xx with a JSON body
When it happens
Trigger: mutateAsync disconnect with an empty/undefined connectionId, or runReauthableAction resolving without running the callback because re-auth was dismissed or its contract changed.
Common situations: Disconnect clicked on a row whose connection was already removed server-side and locally refetched away; expired Den session with cancelled re-auth; refactor changed the wrapper's return behavior.
Understand the failure class
Background: "empty response", "returned no data", "empty embeddings": what HTTP 200-with-empty-body errors mean across libraries — this error's family across 36 libraries.
Related errors
- Update MCP connection response was incomplete.
- OAuth issuer review response was incomplete.
- Update connection access response was incomplete.
- Delete MCP connection response was incomplete.
- Failed to create the dashboard (${response.status}).
AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01).
Data as JSON: /api/errors/f1b6714e929f1f43.
Report an issue: GitHub.