{"record":{"id":"b4cec4d586651b25","repo":"different-ai/openwork","slug":"failed-to-load-organizations","errorCode":null,"errorMessage":"Failed to load organizations.","messagePattern":"Failed to load organizations\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"ee/apps/den-web/app/(den)/_components/organization-screen.tsx","lineNumber":65,"sourceCode":"    hasMore: orgHasMore,\n    showMore: showMoreOrgs,\n    showSearch: showOrgSearch,\n  } = useOrgListWindow(orgs);\n\n  useEffect(() => {\n    if (!sessionHydrated || !runtimeConfigLoaded) return;\n    if (!user) {\n      router.replace(\"/\");\n      return;\n    }\n\n    let isMounted = true;\n\n    async function loadOrgs() {\n      try {\n        const { response, payload } = await requestJson(\"/v1/me/orgs\", { method: \"GET\" });\n        if (!response.ok) {\n          throw new Error(getErrorMessage(payload, \"Failed to load organizations.\"));\n        }\n\n        if (isMounted) {\n          const parsed = parseOrgListPayload(payload);\n          const nextOrgs = parsed.orgs.map((org) => ({ ...org, isActive: org.slug === parsed.activeOrgSlug }));\n          const targetOrg = nextOrgs.find((org) => org.isActive) ?? nextOrgs[0] ?? null;\n          if (isSingleOrgMode && targetOrg) {\n            router.replace(getOrgDashboardRoute(targetOrg.slug));\n            return;\n          }\n          setOrgs(nextOrgs);\n          setShowCreate(!isSingleOrgMode && nextOrgs.length === 0);\n          setBusy(false);\n        }\n      } catch (err) {\n        if (isMounted) {\n          setError(err instanceof Error ? err.message : \"An error occurred.\");\n          setBusy(false);","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/ee/apps/den-web/app/(den)/_components/organization-screen.tsx#L47-L83","documentation":"organization-screen.tsx throws this as the fallback message when `GET /v1/me/orgs` returns a non-ok status and the response payload carries no usable error message. It is the default surfaced to the UI whenever the org list cannot be fetched.","triggerScenarios":"`requestJson(\"/v1/me/orgs\", { method: \"GET\" })` resolves with response.ok === false and getErrorMessage cannot extract a message from the payload (e.g. empty body, HTML error page, non-JSON).","commonSituations":"Auth token expired/missing so the API returns 401 with an empty body; Den server down or proxying to a 502/503 page; network middleware returning HTML error pages instead of JSON.","solutions":["Check the actual HTTP status of the /v1/me/orgs call in the network tab","Re-authenticate: sign in again to refresh the session token","Verify the Den server is running and reachable at the configured base URL","Add a server-side error body so getErrorMessage returns a meaningful message"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const res = await fetch(\"/v1/me/orgs\");\nif (!res.ok) {\n  console.warn(`org list preflight failed: ${res.status}`);\n}","typeGuard":"function isOrgListPayload(p: unknown): p is { orgs: { slug: string }[]; activeOrgSlug: string | null } {\n  return typeof p === \"object\" && p !== null && \"orgs\" in p && Array.isArray((p as { orgs: unknown }).orgs);\n}","tryCatchPattern":"try {\n  const { response, payload } = await requestJson(\"/v1/me/orgs\", { method: \"GET\" });\n  if (!response.ok) throw new Error(getErrorMessage(payload, \"Failed to load organizations.\"));\n} catch (err) {\n  showRetryableError(\"Could not load your organizations. Check your sign-in and try again.\", { retry: loadOrgs });\n}","preventionTips":["Redirect to sign-in proactively on 401 before hitting org endpoints","Ensure the API always returns a JSON error body with a message field","Add a loading/retry state to the org screen instead of a bare throw","Monitor /v1/me/orgs error rates server-side"],"tags":["http","fetch","den-web","organizations"],"backgroundTag":"api-request-failed","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}