different-ai/openwork · error
Failed to delete the dashboard (${response.status}).
Error message
Failed to delete the dashboard (${response.status}). What it means
Thrown in useDeleteDashboard's mutation when DELETE /v1/dashboards/:id returns neither 204 nor a generic ok status. The 204 carve-out means a body-less success is accepted; anything else non-ok (404, 403, 500...) raises this error with the status embedded in the fallback message.
Source
Thrown at ee/apps/den-web/app/(den)/dashboard/_components/org-dashboards-data.tsx:284
queryClient.invalidateQueries({ queryKey: orgDashboardsQueryKeys.detail(organizationId, dashboardId) });
},
});
}
export function useDeleteDashboard() {
const queryClient = useQueryClient();
const { orgContext, runReauthableAction } = useOrgDashboard();
const organizationId = orgContext?.organization.id ?? "";
return useMutation({
mutationFn: async (input: { dashboardId: string }) => {
await runReauthableAction("delete-dashboard", async () => {
const { response, payload } = await requestJson(
`/v1/dashboards/${encodeURIComponent(input.dashboardId)}`,
{ method: "DELETE" },
15000,
);
if (response.status !== 204 && !response.ok) {
throw getRequestError(payload, response, `Failed to delete the dashboard (${response.status}).`);
}
});
},
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: orgDashboardsQueryKeys.list(organizationId) });
},
});
}
export function useDashboardAccess(dashboardId: string) {
const { orgContext } = useOrgDashboard();
const organizationId = orgContext?.organization.id ?? "";
return useQuery({
enabled: Boolean(organizationId && dashboardId),
queryKey: orgDashboardsQueryKeys.access(organizationId, dashboardId),
queryFn: async (): Promise<DashboardAccessGrant[]> => {
const { response, payload } = await requestJson(
`/v1/dashboards/${encodeURIComponent(dashboardId)}/access`,View on GitHub (pinned to 2b7df46e8a)
Solutions
- On 404, refresh the dashboard list — the dashboard is already gone; treat as success for the user.
- On 401/403, re-authenticate or verify org permissions (handle ReauthRequiredError via isReauthRequiredError).
- On 5xx, retry after the server recovers; check whether the deletion actually landed before retrying to avoid double-delete confusion.
- Ensure dashboardId is passed through encodeURIComponent (it is here) and is a valid ID.
Example fix
// before
if (response.status !== 204 && !response.ok) {
throw getRequestError(payload, response, `Failed to delete the dashboard (${response.status}).`);
}
// after
if (response.status === 404) return; // already deleted concurrently
if (response.status !== 204 && !response.ok) {
throw getRequestError(payload, response, `Failed to delete the dashboard (${response.status}).`);
} Defensive patterns
Strategy: retry
Validate before calling
if (!input.dashboardId || typeof input.dashboardId !== "string") {
throw new Error("A valid dashboardId is required to delete a dashboard.");
} Type guard
function isDashboardId(value: unknown): value is string {
return typeof value === "string" && value.length > 0;
} Try / catch
try {
await deleteDashboard.mutateAsync({ dashboardId });
} catch (error) {
if (isReauthRequiredError(error)) return startReauth();
if (error.message.includes("(404)")) return; // already deleted; refetch list
toast.error(error.message);
} finally {
await queryClient.invalidateQueries({ queryKey: orgDashboardsQueryKeys.list(organizationId) });
} Prevention
- Always invalidate the list after delete, even on 404, so the UI reflects reality.
- Confirm deletion intent (confirm dialog) to avoid accidental deletes that surface as conflicts later.
- Check whether a 5xx delete actually landed before retrying.
- Keep permissions for dashboard delete in mind when hiding/showing the delete action.
When it happens
Trigger: Deleting a dashboard that no longer exists (404, e.g. deleted concurrently), lacking delete permission (403), expired session (401), or a server error during cascade deletion of dashboard elements.
Common situations: Clicking delete on a stale list after another admin removed the dashboard; role revoked mid-session; backend failure while removing associated grants/elements.
Related errors
- Failed to create the dashboard (${response.status}).
- Failed to update the dashboard (${response.status}).
- Failed to grant dashboard access (${response.status}).
- Failed to revoke dashboard access (${response.status}).
- Failed to load dashboards (${response.status}).
AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01).
Data as JSON: /api/errors/7d9679c101c58dd7.
Report an issue: GitHub.