{"record":{"id":"5509f4bcb22114a5","repo":"different-ai/openwork","slug":"failed-to-preview-github-plugin","errorCode":null,"errorMessage":"Failed to preview GitHub plugin.","messagePattern":"Failed to preview GitHub plugin\\.","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"ee/apps/den-web/app/(den)/dashboard/_components/mcp-connections-screen.tsx","lineNumber":993,"sourceCode":"  );\n\n  async function previewGithubPlugin() {\n    if (!githubUrl.trim()) {\n      setError(\"Paste a GitHub plugin URL.\");\n      return;\n    }\n    setBusy(true);\n    setError(null);\n    try {\n      let payload: unknown = null;\n      await runReauthableAction(\"preview-github-connection-plugin\", async () => {\n        const result = await requestJson(\n          \"/v1/plugins/import-mcps-from-github-url/preview\",\n          { method: \"POST\", body: JSON.stringify({ githubUrl: githubUrl.trim() }) },\n          20000,\n        );\n        if (!result.response.ok) {\n          throw getRequestError(result.payload, result.response, \"Failed to preview GitHub plugin.\");\n        }\n        payload = result.payload;\n      });\n      const nextPreview = parseGithubPluginImportPreview(payload);\n      setPreview(nextPreview);\n      setSelectedServerKeys(nextPreview.servers.filter((server) => server.supported).map((server) => server.serverKey));\n      setSelectedSkillKeys(nextPreview.skills.filter((skill) => skill.supported).map((skill) => skill.skillKey));\n    } catch (previewError) {\n      setError(previewError instanceof Error ? previewError.message : \"Failed to preview GitHub plugin.\");\n    } finally {\n      setBusy(false);\n    }\n  }\n\n  async function importGithubPlugin() {\n    if (!preview) {\n      setError(\"Preview the GitHub plugin first.\");\n      return;","sourceCodeStart":975,"sourceCodeEnd":1011,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/ee/apps/den-web/app/(den)/dashboard/_components/mcp-connections-screen.tsx#L975-L1011","documentation":"Thrown by the GitHub plugin import preview flow in mcp-connections-screen.tsx when POST /v1/plugins/import-mcps-from-github-url/preview returns a non-ok HTTP response. getRequestError extracts the server-provided error message from the JSON payload when present; otherwise it falls back to the literal message 'Failed to preview GitHub plugin.'. A 403 response with payload.error === 'reauth' is thrown as a ReauthRequiredError instead.","triggerScenarios":"The preview request completes (no network/timeout error) but the Den API returns 4xx/5xx: the githubUrl fails server-side validation, the URL points to a repo that is not a valid MCP config source, the workspace auth token is expired/insufficient, or the server returns 500 while fetching the GitHub repo.","commonSituations":"User pastes a malformed or private GitHub URL (private repo the server cannot read), a repo without a recognizable MCP server config, an expired session token, or the Den backend is down/misconfigured so GitHub fetches fail.","solutions":["Check the thrown error's message for the server-provided detail; if it is the fallback text, inspect the network tab for the actual response status and body of /v1/plugins/import-mcps-from-github-url/preview.","Verify the GitHub URL is public (or that the Den server has credentials for it) and points at a repo containing a supported MCP configuration.","Confirm the dashboard session token is valid; on 403 reauth errors, restart the sign-in flow (the error will be a ReauthRequiredError).","Retry after confirming the Den server is healthy; 5xx indicates a server-side GitHub fetch failure.","If the request times out (20s limit here produces a separate timeout error), check network latency to api.openworklabs.com."],"exampleFix":"// before\nconst result = await requestJson(\"/v1/plugins/import-mcps-from-github-url/preview\", { method: \"POST\", body: JSON.stringify({ githubUrl: githubUrl }) }, 20000);\n// after\nif (!/^https:\\/\\/github\\.com\\/[\\w.-]+\\/[\\w.-]+/.test(githubUrl.trim())) {\n  setPreviewError(\"Enter a valid public GitHub repository URL.\");\n  return;\n}\nconst result = await requestJson(\"/v1/plugins/import-mcps-from-github-url/preview\", { method: \"POST\", body: JSON.stringify({ githubUrl: githubUrl.trim() }) }, 20000);","handlingStrategy":"try-catch","validationCode":"const GITHUB_URL_RE = /^https:\\/\\/github\\.com\\/[\\w.-]+\\/[\\w.-]+/;\nif (!GITHUB_URL_RE.test(githubUrl.trim())) {\n  throw new Error(\"Enter a valid GitHub repository URL before previewing.\");\n}","typeGuard":"function isReauthRequiredError(error: unknown): error is ReauthRequiredError {\n  return error instanceof ReauthRequiredError;\n}","tryCatchPattern":"try {\n  const preview = await previewGithubPlugin(url);\n  setPreview(preview);\n} catch (error) {\n  if (isReauthRequiredError(error)) return startReauth();\n  setPreviewError(error instanceof Error ? error.message : \"Failed to preview GitHub plugin.\");\n}","preventionTips":["Validate the GitHub URL format client-side before calling the preview endpoint.","Only preview public repos unless the server is configured with GitHub credentials.","Handle ReauthRequiredError distinctly so expired sessions trigger the reauth flow.","Show the server's error message (not just the fallback) to aid diagnosis."],"tags":["http","api","github-plugin","preview","network"],"backgroundTag":"http-non-ok-response","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}