different-ai/openwork · error · Error
Failed to delete desktop policy (${response.status}).
Error message
Failed to delete desktop policy (${response.status}). What it means
Thrown by deleteDesktopPolicy when DELETE /v1/desktop-policies/:id returns non-OK. Unlike its create/update siblings there is no 402 special case: getRequestError either throws ReauthRequiredError (403 reauth payload) or an Error with the server message or this fallback. It means the server refused to delete the policy.
Source
Thrown at ee/apps/den-web/app/(den)/dashboard/_components/desktop-policy-data.tsx:222
export async function updateDesktopPolicy(policyId: string, input: DesktopPolicyPayload) {
const { response, payload } = await requestJson(`/v1/desktop-policies/${encodeURIComponent(policyId)}`, {
method: "PATCH",
headers: { "content-type": "application/json" },
body: JSON.stringify(input),
}, 12000);
if (!response.ok) {
if (response.status === 402) throw new Error(DESKTOP_POLICY_ENTERPRISE_PLAN_ERROR);
throw getRequestError(payload, response, `Failed to update desktop policy (${response.status}).`);
}
}
export async function deleteDesktopPolicy(policyId: string) {
const { response, payload } = await requestJson(`/v1/desktop-policies/${encodeURIComponent(policyId)}`, {
method: "DELETE",
}, 12000);
if (!response.ok) {
throw getRequestError(payload, response, `Failed to delete desktop policy (${response.status}).`);
}
}
View on GitHub (pinned to 2b7df46e8a)
Solutions
- If 404, refresh the policy list - the policy is already gone.
- Check whether the policy is default/protected and disable instead of delete.
- Re-authenticate on reauth/session errors and retry.
- Retry as an org admin with policy permissions.
- Inspect server logs for 5xx.
Example fix
// before
if (!response.ok) {
throw getRequestError(payload, response, `Failed to delete desktop policy (${response.status}).`);
}
// after
if (!response.ok) {
if (response.status === 404) return; // already deleted, treat as success
throw getRequestError(payload, response, `Failed to delete desktop policy (${response.status}).`);
} Defensive patterns
Strategy: try-catch
Validate before calling
const policy = policies.find((p) => p.id === policyId);
if (!policy) { refreshPolicies(); return; } // already gone
if (policy.isDefault) { showToast("The default policy cannot be deleted."); return; } Type guard
function isNotFound(error: unknown): boolean { return error instanceof Error && error.message.includes("404"); } Try / catch
try {
await deleteDesktopPolicy(policyId);
} catch (error) {
if (isNotFound(error)) { refreshPolicies(); return; } // idempotent delete
if (isReauthRequiredError(error)) { promptReauth(); return; }
showToast(error.message);
} Prevention
- Treat 404 as success (delete is idempotent) and refresh the list
- Prevent deleting default/protected policies in the UI
- Disable the delete button for non-admins
- Debounce double-clicks on the delete action
When it happens
Trigger: DELETE /v1/desktop-policies/{policyId} fails: policy already deleted (404), protected/default policy that cannot be removed (400/409), insufficient permissions (401/403), or 5xx. 12s timeout. Called from softDeletePolicy.
Common situations: Double-clicking delete (second call 404s); trying to delete the default policy; non-admin session; stale UI after another admin already removed the policy.
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
- Failed to create desktop policy (${response.status}).
- Failed to update desktop policy (${response.status}).
- Failed to load dashboard access (${response.status}).
- Failed to verify skill plugin (${membershipResult.response.s
- Failed to fetch latest-mac.yml (${response.status} ${respons
AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01).
Data as JSON: /api/errors/afd04bc5d84485ab.
Report an issue: GitHub.