different-ai/openwork · error
Failed to delete SSO settings (${response.status}).
Error message
Failed to delete SSO settings (${response.status}). What it means
Thrown by handleDelete when DELETE /v1/sso returns a status other than 204 or a generic non-ok. Note the guard accepts 204 specifically, so 200-with-body is also acceptable. It removes the org's SSO connection; on success it clears connection state, exits editing mode, and reloads the config. Wrapped in runReauthableAction for 403 reauth retry.
Source
Thrown at ee/apps/den-web/app/(den)/dashboard/_components/sso-screen.tsx:228
async function handleDelete() {
if (!access.canManageSso) {
setError("Only workspace owners and super-admins can delete SSO settings.");
return;
}
if (!orgId || !window.confirm("Delete this SSO connection?")) {
return;
}
setError(null);
try {
await runReauthableAction("delete-sso-settings", async () => {
setDeleting(true);
try {
const { response, payload } = await requestJson("/v1/sso", { method: "DELETE", headers: getOrgScopedHeaders() }, 12000);
if (response.status !== 204 && !response.ok) {
throw getRequestError(payload, response, `Failed to delete SSO settings (${response.status}).`);
}
setConnection(null);
setEditing(false);
await loadSsoConfig();
} finally {
setDeleting(false);
}
});
} catch (nextError) {
setError(nextError instanceof Error ? nextError.message : "Failed to delete SSO settings.");
}
}
async function handleRequestDomainToken() {
if (!access.canManageSso) {
setError("Only workspace owners and super-admins can request SSO domain verification tokens.");
return;
}View on GitHub (pinned to 2b7df46e8a)
Solutions
- Read the appended server message — 409-style lockout policies usually explain themselves.
- If 404, the connection is already gone: reload loadSsoConfig and reset UI state instead of showing the error.
- Handle ReauthRequiredError (sign-in prompt) then retry the delete.
- Confirm the org doesn't have a policy requiring SSO; disable the policy in Den first if so.
- Retry on 429/5xx; investigate Den server health if persistent.
Example fix
// before: any failure surfaces error
type status = response.status;
// after: tolerate already-deleted
type="text"
// in handleDelete catch block:
catch (err) {
if (getErrorMessage(err, "").includes("404")) {
setConnection(null); setEditing(false);
return;
}
if (!isReauthRequiredError(err)) setError(getErrorMessage(err, "Failed to delete SSO settings."));
} Defensive patterns
Strategy: try-catch
Validate before calling
if (!connection) return; // nothing to delete; skip the call entirely
Type guard
function isReauthRequiredError(e: unknown): e is ReauthRequiredError {
return e instanceof ReauthRequiredError;
} Try / catch
try {
await deleteSso();
} catch (err) {
if (isReauthRequiredError(err)) { promptSignIn(); return; }
if (/\b404\b/.test(err.message)) { setConnection(null); setEditing(false); await loadSsoConfig(); return; }
if (/\b409\b/.test(err.message)) { setError("Org policy prevents removing SSO; disable the policy first."); return; }
setError(err.message);
} Prevention
- Only render the delete action when a connection exists and the user is an admin.
- Accept 204 (and 2xx) as success — the handler already checks status !== 204 && !ok.
- Check org SSO-enforcement policy before attempting deletion to avoid 409 lockout.
- Always reload loadSsoConfig after deletion so UI state matches the server.
- Handle the 'last admin auth method' protection: warn users before deleting the only admin login path.
When it happens
Trigger: DELETE /v1/sso with org-scoped headers returns 401 (expired token), 403 (not org admin, or reauth challenge), 404 (no SSO connection exists to delete), 409 (SSO connection is enforced by policy or is the only admin auth path — server refuses to remove it), 429, or 5xx. 12s timeout.
Common situations: Admin removes SSO while an org policy marks it mandatory; deleting the last admin auth method is blocked to avoid lockout; concurrent tab already deleted the connection; expired session inside a long-open settings screen.
Understand the failure class
Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.
Related errors
- Could not resolve workspace SSO (${response.status}).
- Failed to delete skill (${response.status}).
- Failed to load SSO settings (${response.status}).
- Failed to save SSO settings (${response.status}).
- Failed to request domain verification (${response.status}).
AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01).
Data as JSON: /api/errors/c65c8556b228cbfa.
Report an issue: GitHub.