{"record":{"id":"b6f4b2ea7782ef39","repo":"different-ai/openwork","slug":"failed-to-configure-plugin-connection-response","errorCode":null,"errorMessage":"Failed to configure plugin connection (${response.status}).","messagePattern":"Failed to configure plugin connection \\((.+?)\\)\\.","errorType":"http","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"ee/apps/den-web/app/(den)/dashboard/_components/marketplace-data.tsx","lineNumber":392,"sourceCode":"      let configured: ConfiguredPluginMcpConnection | null = null;\n      await runReauthableAction(\"configure-plugin-mcp-connection\", async () => {\n        const { response, payload } = await requestJson(\n          `/v1/plugins/${encodeURIComponent(input.pluginId)}/mcp-connections`,\n          {\n            method: \"POST\",\n            body: JSON.stringify({\n              configObjectId: input.configObjectId,\n              serverName: input.serverName,\n              authType: input.authType,\n              credentialMode: input.credentialMode,\n              ...(input.apiKey ? { apiKey: input.apiKey } : {}),\n              ...(input.oauthClient ? { oauthClient: input.oauthClient } : {}),\n            }),\n          },\n          20000,\n        );\n        if (!response.ok) {\n          throw getRequestError(payload, response, `Failed to configure plugin connection (${response.status}).`);\n        }\n        configured = parseConfiguredPluginMcpConnection(payload);\n      });\n      if (!configured) throw new Error(\"Plugin MCP setup response was incomplete.\");\n      return configured;\n    },\n    onSuccess: () => {\n      queryClient.invalidateQueries({ queryKey: marketplaceQueryKeys.all });\n      queryClient.invalidateQueries({ queryKey: mcpConnectionQueryKeys.all });\n    },\n  });\n}\n\nexport function useMarketplaces() {\n  return useQuery({\n    queryKey: marketplaceQueryKeys.list(),\n    queryFn: async () => {\n      const { response, payload } = await requestJson(","sourceCodeStart":374,"sourceCodeEnd":410,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/ee/apps/den-web/app/(den)/dashboard/_components/marketplace-data.tsx#L374-L410","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nconst configured = await configureConnection(input); // generic Error surfaces\n// after\ntry {\n  const configured = await configureConnection(input);\n} catch (err) {\n  if (isReauthRequiredError(err)) { startReauth(); return; }\n  showToast(`Plugin setup failed: ${err.message}`); // includes status or server reason\n}","handlingStrategy":"try-catch","validationCode":"// before calling configureConnection\nif (!orgId) throw new Error(\"Select an organization before configuring a plugin connection\");\nif (input.oauthClient && typeof input.oauthClient !== \"object\") throw new Error(\"Invalid oauthClient payload\");","typeGuard":"function isReauthError(err: unknown): err is ReauthRequiredError {\n  return err instanceof ReauthRequiredError;\n}","tryCatchPattern":"try {\n  await configureConnection(input);\n} catch (err) {\n  if (isReauthRequiredError(err)) { startReauth(); }\n  else reportError(err); // message already carries the HTTP status or server reason\n}","preventionTips":["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"],"tags":["http","den-api","mcp","plugin-connection"],"backgroundTag":"http-request-failed","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}