different-ai/openwork · error

Failed to load SCIM settings (${response.status}).

Error message

Failed to load SCIM settings (${response.status}).

What it means

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.

Source

Thrown at ee/apps/den-web/app/(den)/dashboard/_components/scim-screen.tsx:90

          lastFailureMessage: null,
          nextRetryAt: null,
          lastSuccessfulSyncAt: null,
        });
      }
      return;
    }

    setBusy(true);
    setError(null);
    try {
      const { response, payload } = await requestJson(
        "/v1/scim",
        { method: "GET" },
        12000,
      );

      if (!response.ok) {
        throw getRequestError(payload, response, `Failed to load SCIM settings (${response.status}).`);
      }

      const parsed = parseOrgScimPayload(payload);
      if (isCurrent()) {
        setBaseUrl(parsed.baseUrl);
        setSsoReady(parsed.ssoReady);
        setConnection(parsed.connection);
        setHealth(parsed.health);
      }
    } catch (nextError) {
      if (isReauthRequiredError(nextError)) {
        throw nextError;
      }

      if (isCurrent()) {
        setError(
          nextError instanceof Error ? nextError.message : "Failed to load SCIM settings.",
        );

View on GitHub (pinned to 2b7df46e8a)

Solutions

  1. Check status: 401 -> sign in again; 403 -> use an org-admin account; 404 -> confirm SCIM/SSO is provisioned for the org.
  2. Reload the page to retry after transient 5xx.
  3. Verify Den server health if timeouts repeat.
  4. Confirm the current user's role still includes directory/settings access.

Example fix

// before: silent unguarded load on mount
useEffect(() => { void loadScimConfig(); }, []);
// after: handle auth/permission errors distinctly
useEffect(() => {
  loadScimConfig().catch((e) => {
    if (String(e).includes('401')) redirectToSignIn();
    else showSettingsError(e);
  });
}, []);
Defensive patterns

Strategy: retry

Validate before calling

// ensure an authenticated admin session before mounting the screen
const session = await auth.getSession();
if (!session) redirectToSignIn();

Type guard

function isScimPayload(v: unknown): v is { baseUrl: string; ssoReady: boolean } {
  return typeof v === 'object' && v !== null &&
    typeof (v as Record<string, unknown>).baseUrl === 'string';
}

Try / catch

async function loadWithRetry() {
  for (let attempt = 0; attempt < 2; attempt++) {
    try { return await loadScimConfig(); }
    catch (e) {
      const msg = e instanceof Error ? e.message : String(e);
      if (!/\(5|timed out|timeout/i.test(msg) || attempt === 1) {
        if (msg.includes('401')) return redirectToSignIn();
        toast(msg);
        return;
      }
      await new Promise((r) => setTimeout(r, 1000));
    }
  }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01). Data as JSON: /api/errors/94e087135d909eca. Report an issue: GitHub.