{"record":{"id":"238370b30e86adf9","repo":"different-ai/openwork","slug":"failed-to-create-the-dashboard-response-status","errorCode":null,"errorMessage":"Failed to create the dashboard (${response.status}).","messagePattern":"Failed to create the dashboard \\((.+?)\\)\\.","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"ee/apps/den-web/app/(den)/dashboard/_components/org-dashboards-data.tsx","lineNumber":227,"sourceCode":"    },\n  });\n}\n\nexport function useCreateDashboard() {\n  const queryClient = useQueryClient();\n  const { orgContext, runReauthableAction } = useOrgDashboard();\n  const organizationId = orgContext?.organization.id ?? \"\";\n  return useMutation({\n    mutationFn: async (input: { name: string }): Promise<ManagedDashboard> => {\n      let created: ManagedDashboard | null = null;\n      await runReauthableAction(\"create-dashboard\", async () => {\n        const { response, payload } = await requestJson(\n          \"/v1/dashboards\",\n          { method: \"POST\", body: JSON.stringify({ name: input.name }) },\n          15000,\n        );\n        if (!response.ok) {\n          throw getRequestError(payload, response, `Failed to create the dashboard (${response.status}).`);\n        }\n        created = isRecord(payload) ? parseDashboard(payload.item) : null;\n      });\n      if (!created) throw new Error(\"The dashboard response was invalid.\");\n      return created;\n    },\n    onSuccess: () => {\n      queryClient.invalidateQueries({ queryKey: orgDashboardsQueryKeys.list(organizationId) });\n    },\n  });\n}\n\nexport function useUpdateDashboard() {\n  const queryClient = useQueryClient();\n  const { orgContext, runReauthableAction } = useOrgDashboard();\n  const organizationId = orgContext?.organization.id ?? \"\";\n  return useMutation({\n    mutationFn: async (input: { dashboardId: string; name?: string; elements?: DashboardElement[] }) => {","sourceCodeStart":209,"sourceCodeEnd":245,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/ee/apps/den-web/app/(den)/dashboard/_components/org-dashboards-data.tsx#L209-L245","documentation":"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.","triggerScenarios":"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.","commonSituations":"Submitting the create-dashboard form while logged out or after session expiry, an org role without dashboard create permissions, or backend downtime during deploys.","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."],"exampleFix":"// before\nconst { response, payload } = await requestJson(\"/v1/dashboards\", { method: \"POST\", body: JSON.stringify({ name: input.name }) }, 15000);\n// after\nconst name = input.name.trim();\nif (!name || name.length > 100) throw new Error(\"Dashboard name must be 1-100 characters.\");\nconst { response, payload } = await requestJson(\"/v1/dashboards\", { method: \"POST\", body: JSON.stringify({ name }) }, 15000);","handlingStrategy":"validation","validationCode":"const name = input.name.trim();\nif (!name) throw new Error(\"Dashboard name is required.\");\nif (name.length > 100) throw new Error(\"Dashboard name must be 100 characters or fewer.\");","typeGuard":"function isRecord(value: unknown): value is Record<string, unknown> {\n  return typeof value === \"object\" && value !== null;\n}","tryCatchPattern":"const createDashboard = useCreateDashboard(organizationId);\ntry {\n  await createDashboard.mutateAsync({ name });\n} catch (error) {\n  if (isReauthRequiredError(error)) return startReauth();\n  toast.error(error.message); // includes HTTP status from the fallback\n}","preventionTips":["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."],"tags":["http","api","dashboard","react-query","mutation"],"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"}