different-ai/openwork · error · Error
Failed to configure plugin connection (${response.status}).
Error message
Failed to configure plugin connection (${response.status}). What it means
This error is thrown by useConfigurePluginMcpConnection in marketplace-data.tsx when the POST to the plugin MCP connection configure endpoint returns a non-2xx HTTP status. It passes through getRequestError (den-flow.ts:527), which prefers a server-provided error message from the JSON payload and otherwise uses the fallback string 'Failed to configure plugin connection (<status>)'. A 403 with payload.error==='reauth' is converted to a ReauthRequiredError instead. In short: the server rejected the configure call at the HTTP level.
Source
Thrown at ee/apps/den-web/app/(den)/dashboard/_components/marketplace-data.tsx:392
let configured: ConfiguredPluginMcpConnection | null = null;
await runReauthableAction("configure-plugin-mcp-connection", async () => {
const { response, payload } = await requestJson(
`/v1/plugins/${encodeURIComponent(input.pluginId)}/mcp-connections`,
{
method: "POST",
body: JSON.stringify({
configObjectId: input.configObjectId,
serverName: input.serverName,
authType: input.authType,
credentialMode: input.credentialMode,
...(input.apiKey ? { apiKey: input.apiKey } : {}),
...(input.oauthClient ? { oauthClient: input.oauthClient } : {}),
}),
},
20000,
);
if (!response.ok) {
throw getRequestError(payload, response, `Failed to configure plugin connection (${response.status}).`);
}
configured = parseConfiguredPluginMcpConnection(payload);
});
if (!configured) throw new Error("Plugin MCP setup response was incomplete.");
return configured;
},
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: marketplaceQueryKeys.all });
queryClient.invalidateQueries({ queryKey: mcpConnectionQueryKeys.all });
},
});
}
export function useMarketplaces() {
return useQuery({
queryKey: marketplaceQueryKeys.list(),
queryFn: async () => {
const { response, payload } = await requestJson(View on GitHub (pinned to 2b7df46e8a)
Solutions
- Read the thrown message (or response.status): if 401/403, re-authenticate with Den and ensure the org scope headers include a valid requireOrgId(orgId).
- If 404, verify the plugin/connection id still exists and the marketplace listing is current (invalidate marketplace queries and retry).
- If 400/422, inspect the request body (oauthClient and config fields) against the server schema and fix invalid values.
- If 5xx, retry after a short delay and check Den server logs/health; if persistent, escalate to the server operator.
- Handle isReauthRequiredError(err) specially in the caller so the workspace re-auth flow runs instead of showing a generic failure.
Example fix
// before
const configured = await configureConnection(input); // generic Error surfaces
// after
try {
const configured = await configureConnection(input);
} catch (err) {
if (isReauthRequiredError(err)) { startReauth(); return; }
showToast(`Plugin setup failed: ${err.message}`); // includes status or server reason
} Defensive patterns
Strategy: try-catch
Validate before calling
// before calling configureConnection
if (!orgId) throw new Error("Select an organization before configuring a plugin connection");
if (input.oauthClient && typeof input.oauthClient !== "object") throw new Error("Invalid oauthClient payload"); Type guard
function isReauthError(err: unknown): err is ReauthRequiredError {
return err instanceof ReauthRequiredError;
} Try / catch
try {
await configureConnection(input);
} catch (err) {
if (isReauthRequiredError(err)) { startReauth(); }
else reportError(err); // message already carries the HTTP status or server reason
} Prevention
- Always pass a valid orgId so getOrgScopeHeaders/requireOrgId produce correct scope headers
- Check session validity before long marketplace flows; refresh tokens proactively
- Validate config/oauthClient fields against the API schema before submit
- Keep Den server and web client versions in sync to avoid 404/400 from schema drift
When it happens
Trigger: Any non-ok response from the configure endpoint (called with a 20000ms timeout inside requestJson): 401/403 when the Den session or org scope headers are missing/insufficient, 404 when the plugin connection id does not exist, 400/422 when the submitted oauthClient or configuration payload fails server validation, 500-level when the Den server fails while provisioning the MCP connection, or a timeout/aborted request surfacing an error status.
Common situations: Expired Den session causing 401/403; the plugin was unpublished from the marketplace so its connection id 404s; org policy blocking plugin MCP setup; malformed oauthClient metadata; Den server deploy/migration in progress returning 5xx; gateway timeouts on slow plugin handshakes.
Understand the failure class
Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.
Related errors
- Failed to inspect MCP tools (${response.status}).
- Failed to update MCP tool policy (${response.status}).
- Failed to load MCP connectors (${response.status}).
- Failed to load MCP presets (${response.status}).
- Failed to look up the MCP server (${response.status}).
AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01).
Data as JSON: /api/errors/b6f4b2ea7782ef39.
Report an issue: GitHub.