different-ai/openwork · error
Failed to create the dashboard (${response.status}).
Error message
Failed to create the dashboard (${response.status}). What it means
Thrown inside useCreateDashboard's mutation when POST /v1/dashboards responds with a non-ok status (e.g. 400/401/403/500); the status code is embedded in the fallback message. The mutation then surfaces it via React Query's error state. A 403 payload with error 'reauth' is thrown as ReauthRequiredError instead of this message.
Source
Thrown at ee/apps/den-web/app/(den)/dashboard/_components/org-dashboards-data.tsx:227
},
});
}
export function useCreateDashboard() {
const queryClient = useQueryClient();
const { orgContext, runReauthableAction } = useOrgDashboard();
const organizationId = orgContext?.organization.id ?? "";
return useMutation({
mutationFn: async (input: { name: string }): Promise<ManagedDashboard> => {
let created: ManagedDashboard | null = null;
await runReauthableAction("create-dashboard", async () => {
const { response, payload } = await requestJson(
"/v1/dashboards",
{ method: "POST", body: JSON.stringify({ name: input.name }) },
15000,
);
if (!response.ok) {
throw getRequestError(payload, response, `Failed to create the dashboard (${response.status}).`);
}
created = isRecord(payload) ? parseDashboard(payload.item) : null;
});
if (!created) throw new Error("The dashboard response was invalid.");
return created;
},
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: orgDashboardsQueryKeys.list(organizationId) });
},
});
}
export function useUpdateDashboard() {
const queryClient = useQueryClient();
const { orgContext, runReauthableAction } = useOrgDashboard();
const organizationId = orgContext?.organization.id ?? "";
return useMutation({
mutationFn: async (input: { dashboardId: string; name?: string; elements?: DashboardElement[] }) => {View on GitHub (pinned to 2b7df46e8a)
Solutions
- Read the status in the message: 400 → fix the name input; 401 → sign in again; 403 → check org permissions (or reauth error); 5xx → retry after server recovery.
- Validate the dashboard name client-side (non-empty, length limits) before submitting the mutation.
- Refresh the session token if other Den API calls are also failing with 401.
- Verify the correct organizationId/workspace context is active in the dashboard session.
Example fix
// before
const { response, payload } = await requestJson("/v1/dashboards", { method: "POST", body: JSON.stringify({ name: input.name }) }, 15000);
// after
const name = input.name.trim();
if (!name || name.length > 100) throw new Error("Dashboard name must be 1-100 characters.");
const { response, payload } = await requestJson("/v1/dashboards", { method: "POST", body: JSON.stringify({ name }) }, 15000); Defensive patterns
Strategy: validation
Validate before calling
const name = input.name.trim();
if (!name) throw new Error("Dashboard name is required.");
if (name.length > 100) throw new Error("Dashboard name must be 100 characters or fewer."); Type guard
function isRecord(value: unknown): value is Record<string, unknown> {
return typeof value === "object" && value !== null;
} Try / catch
const createDashboard = useCreateDashboard(organizationId);
try {
await createDashboard.mutateAsync({ name });
} catch (error) {
if (isReauthRequiredError(error)) return startReauth();
toast.error(error.message); // includes HTTP status from the fallback
} Prevention
- Validate the dashboard name (non-empty, length limits) before calling the mutation.
- Keep the session token fresh; redirect to sign-in on 401.
- Verify the user's org role grants dashboard-create permission.
- Surface React Query mutation.error in the UI instead of swallowing it.
When it happens
Trigger: Creating a dashboard when the request body's name is rejected by validation (empty/too long/duplicate naming rules), the auth token is missing or expired, the user lacks permission in the organization, or the Den API returns a server error.
Common situations: Submitting the create-dashboard form while logged out or after session expiry, an org role without dashboard create permissions, or backend downtime during deploys.
Related errors
- Failed to update 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/238370b30e86adf9.
Report an issue: GitHub.