different-ai/openwork · error
Failed to update the dashboard (${response.status}).
Error message
Failed to update the dashboard (${response.status}). What it means
Thrown in useUpdateDashboard's mutation when the PATCH to /v1/dashboards/:id returns non-ok. The fallback message includes the HTTP status; the server's error message takes precedence when present. React Query's updateMutation surfaces it through its error channel.
Source
Thrown at ee/apps/den-web/app/(den)/dashboard/_components/org-dashboards-data.tsx:259
const queryClient = useQueryClient();
const { orgContext, runReauthableAction } = useOrgDashboard();
const organizationId = orgContext?.organization.id ?? "";
return useMutation({
mutationFn: async (input: { dashboardId: string; name?: string; elements?: DashboardElement[] }) => {
await runReauthableAction("update-dashboard", async () => {
const { response, payload } = await requestJson(
`/v1/dashboards/${encodeURIComponent(input.dashboardId)}`,
{
method: "PATCH",
body: JSON.stringify({
...(input.name !== undefined ? { name: input.name } : {}),
...(input.elements !== undefined ? { elements: input.elements } : {}),
}),
},
15000,
);
if (!response.ok) {
throw getRequestError(payload, response, `Failed to update the dashboard (${response.status}).`);
}
});
return input.dashboardId;
},
onSuccess: (dashboardId) => {
queryClient.invalidateQueries({ queryKey: orgDashboardsQueryKeys.list(organizationId) });
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 () => {View on GitHub (pinned to 2b7df46e8a)
Solutions
- Check the status: 404 → refetch the dashboard list (it was deleted); 400 → correct name/elements payload; 401 → re-authenticate; 403 → verify permissions or run reauth.
- Invalidate/refetch orgDashboardsQueryKeys.list before retrying so the UI works against current data.
- Retry the mutation after refetch; if it was a concurrent delete, discard the local edit.
- Confirm the elements payload matches the server schema (only include keys actually changed).
Example fix
// before
onError: () => toast.error("Update failed");
// after
onError: (error) => {
if (isReauthRequiredError(error)) return startReauth();
toast.error(error.message);
void queryClient.invalidateQueries({ queryKey: orgDashboardsQueryKeys.list(organizationId) });
} Defensive patterns
Strategy: try-catch
Validate before calling
if (!input.dashboardId) throw new Error("dashboardId is required.");
if (input.name !== undefined && !input.name.trim()) throw new Error("Dashboard name cannot be empty."); Type guard
function isReauthRequiredError(error: unknown): error is ReauthRequiredError {
return error instanceof ReauthRequiredError;
} Try / catch
try {
await updateDashboard.mutateAsync(input);
} catch (error) {
if (isReauthRequiredError(error)) return startReauth();
if (error.message.includes("(404)")) {
await queryClient.invalidateQueries({ queryKey: orgDashboardsQueryKeys.list(organizationId) });
return toast.error("This dashboard no longer exists.");
}
toast.error(error.message);
} Prevention
- Refetch the dashboard before applying edits from a long-open editor.
- Treat 404 as 'deleted concurrently' and refresh the list rather than retrying blindly.
- Include isReauthRequiredError handling in every dashboard mutation onError path.
- Only send changed fields in the PATCH payload.
When it happens
Trigger: Updating a dashboard that was deleted by another user (404), renaming to an invalid value (400), token expired (401), insufficient org role (403, possibly ReauthRequiredError), or dashboard ID malformed.
Common situations: Two admins editing the same dashboard where one deletes it mid-edit; stale browser tab holding a deleted dashboard; permission downgrades after role changes.
Related errors
- Failed to create the dashboard (${response.status}).
- Failed to delete the dashboard (${response.status}).
- Failed to grant dashboard access (${response.status}).
- Failed to revoke dashboard access (${response.status}).
- Failed to update plugin (${response.status}).
AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01).
Data as JSON: /api/errors/8ba607d9939b0fda.
Report an issue: GitHub.