{"record":{"id":"7d9679c101c58dd7","repo":"different-ai/openwork","slug":"failed-to-delete-the-dashboard-response-status","errorCode":null,"errorMessage":"Failed to delete the dashboard (${response.status}).","messagePattern":"Failed to delete the dashboard \\((.+?)\\)\\.","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"ee/apps/den-web/app/(den)/dashboard/_components/org-dashboards-data.tsx","lineNumber":284,"sourceCode":"      queryClient.invalidateQueries({ queryKey: orgDashboardsQueryKeys.detail(organizationId, dashboardId) });\n    },\n  });\n}\n\nexport function useDeleteDashboard() {\n  const queryClient = useQueryClient();\n  const { orgContext, runReauthableAction } = useOrgDashboard();\n  const organizationId = orgContext?.organization.id ?? \"\";\n  return useMutation({\n    mutationFn: async (input: { dashboardId: string }) => {\n      await runReauthableAction(\"delete-dashboard\", async () => {\n        const { response, payload } = await requestJson(\n          `/v1/dashboards/${encodeURIComponent(input.dashboardId)}`,\n          { method: \"DELETE\" },\n          15000,\n        );\n        if (response.status !== 204 && !response.ok) {\n          throw getRequestError(payload, response, `Failed to delete the dashboard (${response.status}).`);\n        }\n      });\n    },\n    onSuccess: () => {\n      queryClient.invalidateQueries({ queryKey: orgDashboardsQueryKeys.list(organizationId) });\n    },\n  });\n}\n\nexport function useDashboardAccess(dashboardId: string) {\n  const { orgContext } = useOrgDashboard();\n  const organizationId = orgContext?.organization.id ?? \"\";\n  return useQuery({\n    enabled: Boolean(organizationId && dashboardId),\n    queryKey: orgDashboardsQueryKeys.access(organizationId, dashboardId),\n    queryFn: async (): Promise<DashboardAccessGrant[]> => {\n      const { response, payload } = await requestJson(\n        `/v1/dashboards/${encodeURIComponent(dashboardId)}/access`,","sourceCodeStart":266,"sourceCodeEnd":302,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/ee/apps/den-web/app/(den)/dashboard/_components/org-dashboards-data.tsx#L266-L302","documentation":"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.","triggerScenarios":"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.","commonSituations":"Clicking delete on a stale list after another admin removed the dashboard; role revoked mid-session; backend failure while removing associated grants/elements.","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."],"exampleFix":"// before\nif (response.status !== 204 && !response.ok) {\n  throw getRequestError(payload, response, `Failed to delete the dashboard (${response.status}).`);\n}\n// after\nif (response.status === 404) return; // already deleted concurrently\nif (response.status !== 204 && !response.ok) {\n  throw getRequestError(payload, response, `Failed to delete the dashboard (${response.status}).`);\n}","handlingStrategy":"retry","validationCode":"if (!input.dashboardId || typeof input.dashboardId !== \"string\") {\n  throw new Error(\"A valid dashboardId is required to delete a dashboard.\");\n}","typeGuard":"function isDashboardId(value: unknown): value is string {\n  return typeof value === \"string\" && value.length > 0;\n}","tryCatchPattern":"try {\n  await deleteDashboard.mutateAsync({ dashboardId });\n} catch (error) {\n  if (isReauthRequiredError(error)) return startReauth();\n  if (error.message.includes(\"(404)\")) return; // already deleted; refetch list\n  toast.error(error.message);\n} finally {\n  await queryClient.invalidateQueries({ queryKey: orgDashboardsQueryKeys.list(organizationId) });\n}","preventionTips":["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."],"tags":["http","api","dashboard","delete","react-query"],"backgroundTag":"http-non-ok-response","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}