{"record":{"id":"67b2dbdfe72d51bd","repo":"different-ai/openwork","slug":"egress-diagnostic-could-not-start-response-stat","errorCode":null,"errorMessage":"Egress diagnostic could not start (${response.status}).","messagePattern":"Egress diagnostic could not start \\((.+?)\\)\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"ee/apps/den-web/app/(den)/dashboard/_components/egress-diagnostics-card.tsx","lineNumber":143,"sourceCode":"  useEffect(() => {\n    if (!copied) return;\n    const timeout = window.setTimeout(() => setCopied(false), 1_600);\n    return () => window.clearTimeout(timeout);\n  }, [copied]);\n\n  async function runDiagnostic() {\n    if (!canManage) {\n      setError(\"Only workspace owners and super-admins can run this diagnostic.\");\n      return;\n    }\n\n    setRunning(true);\n    setError(null);\n    setResult(null);\n    try {\n      const { response, payload } = await requestJson(\"/v1/diagnostics/egress\", { method: \"POST\" }, 90_000);\n      if (!response.ok) {\n        throw new Error(getErrorMessage(payload, `Egress diagnostic could not start (${response.status}).`));\n      }\n      const parsed = egressDiagnosticRunSchema.safeParse(payload);\n      if (!parsed.success) throw new Error(\"Den returned an invalid egress diagnostic result.\");\n      setResult(parsed.data);\n    } catch (runError) {\n      setError(runError instanceof Error ? runError.message : \"Egress diagnostic could not complete.\");\n    } finally {\n      setRunning(false);\n    }\n  }\n\n  async function saveBearerToken() {\n    if (!canManage) {\n      setError(\"Only workspace owners and super-admins can change the diagnostic token.\");\n      return;\n    }\n\n    const bearerToken = bearerTokenDraft.trim();","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/ee/apps/den-web/app/(den)/dashboard/_components/egress-diagnostics-card.tsx#L125-L161","documentation":"runDiagnostic POSTs /v1/diagnostics/egress with a long 90s timeout to execute an egress connectivity test. A non-OK response throws `Egress diagnostic could not start (${response.status})`, unless the payload supplies a server message via getErrorMessage. The error is caught and shown via setError; running state is reset in the finally block.","triggerScenarios":"POST /v1/diagnostics/egress returns 400 (diagnostics unavailable or bad request), 401/403 (auth/permission), 402 (feature gating), 409/503 (diagnostic already running or backend busy), or 5xx from the Den backend. Also surfaces when requestJson's 90s timeout aborts and the catch falls back to the generic completion message.","commonSituations":"Clicking Run diagnostic before the bearer token is configured (server refuses to start); two admins racing to run the diagnostic; Den worker failing to reach the target origin and erroring out; expired session.","solutions":["Check the HTTP status and the Den server logs for the POST to /v1/diagnostics/egress to identify the server-side refusal reason.","Ensure required configuration (e.g. the diagnostic bearer token) is saved first — use the token editor to PUT /v1/diagnostics/egress/token, then retry.","If a diagnostic is already running (409), wait for it to finish and retry.","Re-authenticate on 401/403; verify admin permissions.","For 5xx, restart/inspect the Den diagnostics worker and retry after it recovers."],"exampleFix":"// before: run diagnostic without a stored token -> server 400\nawait runDiagnostic(); // \"Egress diagnostic could not start (400).\"\n\n// after: save the token first, then run\nawait saveBearerToken(); // PUT /v1/diagnostics/egress/token\nawait runDiagnostic();","handlingStrategy":"try-catch","validationCode":"if (!diagnosticsConfigured) {\n  openTokenEditor(); // save bearer token via PUT /v1/diagnostics/egress/token first\n  return;\n}","typeGuard":"function isHttpError(e: unknown): e is Error & { status?: number } {\n  return e instanceof Error && /\\(\\d{3}\\)/.test(e.message);\n}","tryCatchPattern":"try {\n  await runDiagnostic();\n} catch (e) {\n  if (isHttpError(e) && e.message.includes(\"409\")) {\n    showError(\"A diagnostic is already running; try again shortly.\");\n  } else {\n    showError(e instanceof Error ? e.message : \"Egress diagnostic could not complete.\");\n  }\n}","preventionTips":["Complete token configuration before exposing the Run button.","Disable the Run button while a diagnostic is in flight to avoid 409 races.","Keep the 90s timeout generous but show progress so users don't retrigger.","Re-authenticate expired sessions before long-running diagnostic calls."],"tags":["network","http","diagnostics","api"],"backgroundTag":"http-request-failed","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}