{"record":{"id":"94e087135d909eca","repo":"different-ai/openwork","slug":"failed-to-load-scim-settings-response-status","errorCode":null,"errorMessage":"Failed to load SCIM settings (${response.status}).","messagePattern":"Failed to load SCIM settings \\((.+?)\\)\\.","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"ee/apps/den-web/app/(den)/dashboard/_components/scim-screen.tsx","lineNumber":90,"sourceCode":"          lastFailureMessage: null,\n          nextRetryAt: null,\n          lastSuccessfulSyncAt: null,\n        });\n      }\n      return;\n    }\n\n    setBusy(true);\n    setError(null);\n    try {\n      const { response, payload } = await requestJson(\n        \"/v1/scim\",\n        { method: \"GET\" },\n        12000,\n      );\n\n      if (!response.ok) {\n        throw getRequestError(payload, response, `Failed to load SCIM settings (${response.status}).`);\n      }\n\n      const parsed = parseOrgScimPayload(payload);\n      if (isCurrent()) {\n        setBaseUrl(parsed.baseUrl);\n        setSsoReady(parsed.ssoReady);\n        setConnection(parsed.connection);\n        setHealth(parsed.health);\n      }\n    } catch (nextError) {\n      if (isReauthRequiredError(nextError)) {\n        throw nextError;\n      }\n\n      if (isCurrent()) {\n        setError(\n          nextError instanceof Error ? nextError.message : \"Failed to load SCIM settings.\",\n        );","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/ee/apps/den-web/app/(den)/dashboard/_components/scim-screen.tsx#L72-L108","documentation":"loadScimConfig in scim-screen.tsx throws this when GET /v1/scim returns non-ok within its 12s timeout. It is called on mount and after mutations, so the SCIM settings screen fails to render connection data. getRequestError attaches the payload for the underlying cause.","triggerScenarios":"GET /v1/scim returns 401 (expired session), 403 (non-admin viewer), 404 (SCIM never provisioned for the org), or 5xx from the Den API. Also fires when the 12s timeout elapses on a slow server.","commonSituations":"Opening the SCIM settings page after a session expired; a non-admin navigating directly to the settings URL; org without SCIM configured hitting an unexpected 404; transient server outage.","solutions":["Check status: 401 -> sign in again; 403 -> use an org-admin account; 404 -> confirm SCIM/SSO is provisioned for the org.","Reload the page to retry after transient 5xx.","Verify Den server health if timeouts repeat.","Confirm the current user's role still includes directory/settings access."],"exampleFix":"// before: silent unguarded load on mount\nuseEffect(() => { void loadScimConfig(); }, []);\n// after: handle auth/permission errors distinctly\nuseEffect(() => {\n  loadScimConfig().catch((e) => {\n    if (String(e).includes('401')) redirectToSignIn();\n    else showSettingsError(e);\n  });\n}, []);","handlingStrategy":"retry","validationCode":"// ensure an authenticated admin session before mounting the screen\nconst session = await auth.getSession();\nif (!session) redirectToSignIn();","typeGuard":"function isScimPayload(v: unknown): v is { baseUrl: string; ssoReady: boolean } {\n  return typeof v === 'object' && v !== null &&\n    typeof (v as Record<string, unknown>).baseUrl === 'string';\n}","tryCatchPattern":"async function loadWithRetry() {\n  for (let attempt = 0; attempt < 2; attempt++) {\n    try { return await loadScimConfig(); }\n    catch (e) {\n      const msg = e instanceof Error ? e.message : String(e);\n      if (!/\\(5|timed out|timeout/i.test(msg) || attempt === 1) {\n        if (msg.includes('401')) return redirectToSignIn();\n        toast(msg);\n        return;\n      }\n      await new Promise((r) => setTimeout(r, 1000));\n    }\n  }\n}","preventionTips":["Verify the user is signed in and is an org admin before rendering the SCIM screen.","Handle 404 (no SCIM provisioned) as an empty state, not an error toast.","Auto-retry transient 5xx/timeout once with backoff.","Monitor Den API latency; 12s is tight for slow deployments."],"tags":["http","api","scim","permissions"],"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"}