{"record":{"id":"c1f00fc5484d7178","repo":"different-ai/openwork","slug":"could-not-load-egress-diagnostics-response-stat","errorCode":null,"errorMessage":"Could not load egress diagnostics (${response.status}).","messagePattern":"Could not load egress diagnostics \\((.+?)\\)\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"ee/apps/den-web/app/(den)/dashboard/_components/egress-diagnostics-card.tsx","lineNumber":105,"sourceCode":"  const [error, setError] = useState<string | null>(null);\n  const [result, setResult] = useState<EgressDiagnosticRun | null>(null);\n  const [copied, setCopied] = useState(false);\n  const [bearerTokenDraft, setBearerTokenDraft] = useState(\"\");\n  const [savingBearerToken, setSavingBearerToken] = useState(false);\n  const [editingBearerToken, setEditingBearerToken] = useState(false);\n\n  useEffect(() => {\n    if (!canView) {\n      setLoading(false);\n      return;\n    }\n    let cancelled = false;\n    async function loadConfiguration() {\n      setLoading(true);\n      try {\n        const { response, payload } = await requestJson(\"/v1/diagnostics/egress\", { method: \"GET\" }, 12_000);\n        if (!response.ok) {\n          throw new Error(getErrorMessage(payload, `Could not load egress diagnostics (${response.status}).`));\n        }\n        const parsed = egressDiagnosticConfigurationSchema.safeParse(payload);\n        if (!parsed.success) throw new Error(\"Den returned an invalid diagnostics configuration response.\");\n        if (!cancelled) {\n          setAvailable(parsed.data.available);\n          setTargetOrigin(parsed.data.targetOrigin);\n          setMissingConfiguration(parsed.data.missingConfiguration);\n          setError(null);\n        }\n      } catch (loadError) {\n        if (!cancelled) setError(loadError instanceof Error ? loadError.message : \"Could not load egress diagnostics.\");\n      } finally {\n        if (!cancelled) setLoading(false);\n      }\n    }\n    void loadConfiguration();\n    return () => { cancelled = true; };\n  }, [canView]);","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/ee/apps/den-web/app/(den)/dashboard/_components/egress-diagnostics-card.tsx#L87-L123","documentation":"loadConfiguration in EgressDiagnosticsCard fetches GET /v1/diagnostics/egress (12s timeout) to render egress diagnostics availability. On a non-OK response it throws `Could not load egress diagnostics (${response.status})` unless the payload contains a server-provided message, which getErrorMessage prefers. The thrown error is caught and shown via setError, so the card displays the failure instead of diagnostics.","triggerScenarios":"GET /v1/diagnostics/egress returns non-OK: 401/403 (unauthorized/non-admin), 404 (older Den server without the diagnostics endpoint), 5xx (backend error), or plan/feature gating on the diagnostics route. Also displayed when requestJson itself throws and the catch replaces it with the generic fallback string.","commonSituations":"Self-hosted Den version predates the egress diagnostics API; admin session expired; Den service restarting; reverse proxy returning 502/503 during backend deploy.","solutions":["Read the HTTP status in the message and check Den server logs for GET /v1/diagnostics/egress; fix the root cause server-side.","Re-authenticate if the status is 401/403 and confirm the user has admin access to diagnostics.","If the status is 404, upgrade the Den server to a version that ships /v1/diagnostics/egress.","For 5xx/502/503, wait for the backend to recover or restart the Den service, then reload the dashboard."],"exampleFix":"// before\nconst { response, payload } = await requestJson(\"/v1/diagnostics/egress\", { method: \"GET\" }, 12_000);\n// server without endpoint -> 404 -> \"Could not load egress diagnostics (404).\"\n\n// after: run a Den version that implements the diagnostics route\n// (upgrade den-server; then the same call parses egressDiagnosticConfigurationSchema successfully)","handlingStrategy":"try-catch","validationCode":"if (!denSessionActive()) await refreshSession(); // prevent predictable 401 before loadConfiguration()","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 loadConfiguration();\n} catch (e) {\n  if (isHttpError(e) && e.message.includes(\"404\")) {\n    showNotice(\"Egress diagnostics unavailable on this Den server version.\");\n  } else {\n    showError(e instanceof Error ? e.message : \"Could not load egress diagnostics.\");\n  }\n}","preventionTips":["Feature-detect the diagnostics endpoint (or a capabilities route) before rendering the card.","Keep Den server and dashboard versions aligned.","Retry once with short backoff for transient 5xx/502 from proxies.","Ensure the user has admin role before requesting diagnostics."],"tags":["network","http","api","diagnostics"],"backgroundTag":"http-request-failed","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}