different-ai/openwork · error
Failed to delete SCIM connection (${response.status}).
Error message
Failed to delete SCIM connection (${response.status}). What it means
handleDeleteConnection in scim-screen.tsx throws this when DELETE /v1/scim returns a non-ok status other than 204 (204 and general 2xx are treated as success). Deleting the SCIM connection is destructive — it removes provisioning for the org — so the error means the server refused the removal. Cleanup (clearing token state and reloading config) only runs on success.
Source
Thrown at ee/apps/den-web/app/(den)/dashboard/_components/scim-screen.tsx:303
"Delete this SCIM connection? The current bearer token will stop working immediately.",
)
) {
return;
}
setError(null);
try {
await runReauthableAction("delete-scim-connection", async () => {
setDeleting(true);
try {
const { response, payload } = await requestJson(
"/v1/scim",
{ method: "DELETE" },
12000,
);
if (response.status !== 204 && !response.ok) {
throw getRequestError(payload, response, `Failed to delete SCIM connection (${response.status}).`);
}
setConnection(null);
setVisibleToken(null);
setCopiedValue(null);
await loadScimConfig();
} finally {
setDeleting(false);
}
});
} catch (nextError) {
setError(
nextError instanceof Error ? nextError.message : "Failed to delete SCIM connection.",
);
}
}
if (!orgContext) {View on GitHub (pinned to 2b7df46e8a)
Solutions
- Check status: 404 -> the connection is already gone; just reload the settings screen.
- For 401, sign in again; for 403, use an org-admin account.
- Retry once after transient 5xx, confirming no other admin deleted it concurrently.
- After any failure, reload SCIM config to resync local state before retrying.
Example fix
// before: blind delete
await deleteConnection();
// after: tolerate 'already deleted' gracefully
try {
await deleteConnection();
} catch (e) {
if (!String(e).includes('404')) throw e;
}
await loadScimConfig(); Defensive patterns
Strategy: try-catch
Validate before calling
const ok = window.confirm('Delete the SCIM connection? Provisioning for this org will stop.');
if (!ok) return; Type guard
function isDeletable(v: unknown): v is { connection: Record<string, unknown> } {
return typeof v === 'object' && v !== null &&
(v as Record<string, unknown>).connection != null;
} Try / catch
try {
await deleteConnection();
} catch (e) {
const msg = e instanceof Error ? e.message : String(e);
if (msg.includes('404')) toast('Connection was already deleted.');
else if (msg.includes('403')) toast('Only org admins can delete the SCIM connection.');
else toast(msg);
} finally {
await loadScimConfig(); // resync local state either way
} Prevention
- Always resync SCIM state after delete attempts (success or 'already gone').
- Require a confirmation dialog for this destructive action.
- Handle 404 as success-equivalent to make delete idempotent in the UI.
- Re-authenticate before confirming deletions in long-open tabs.
When it happens
Trigger: DELETE /v1/scim returns 401 (expired session), 403 (non-admin), 404 (connection already deleted elsewhere), or 5xx; anything not 204/ok throws. A concurrent delete by another admin commonly produces the 404 path.
Common situations: Two admins clicking delete simultaneously; deleting after the org's SSO binding already removed SCIM; session expiring between loading the screen and confirming the delete dialog.
Related errors
- Failed to load SCIM settings (${response.status}).
- Failed to rotate SCIM token (${response.status}).
- Failed to reconcile SCIM (${response.status}).
- Failed to update SCIM group mapping (${response.status}).
- request_failed
AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01).
Data as JSON: /api/errors/e758e2e269198525.
Report an issue: GitHub.