{"record":{"id":"f86f9ad84a29d3bb","repo":"different-ai/openwork","slug":"failed-to-load-dashboard-access-response-status","errorCode":null,"errorMessage":"Failed to load dashboard access (${response.status}).","messagePattern":"Failed to load dashboard access \\((.+?)\\)\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"ee/apps/den-web/app/(den)/dashboard/_components/org-dashboards-data.tsx","lineNumber":307,"sourceCode":"      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`,\n        { method: \"GET\" },\n        15000,\n      );\n      if (!response.ok) {\n        throw new Error(getErrorMessage(payload, `Failed to load dashboard access (${response.status}).`));\n      }\n      const items = isRecord(payload) && Array.isArray(payload.items) ? payload.items : [];\n      return items\n        .map(parseAccessGrant)\n        .filter((grant): grant is DashboardAccessGrant => grant !== null && grant.removedAt === null);\n    },\n  });\n}\n\ntype GrantDashboardAccessBody =\n  | { orgMembershipId: string; teamId?: never; orgWide?: never; role: DashboardAccessRole }\n  | { orgMembershipId?: never; teamId: string; orgWide?: never; role: DashboardAccessRole }\n  | { orgMembershipId?: never; teamId?: never; orgWide: true; role: DashboardAccessRole };\n\nexport function useGrantDashboardAccess() {\n  const queryClient = useQueryClient();\n  const { orgContext, runReauthableAction } = useOrgDashboard();\n  const organizationId = orgContext?.organization.id ?? \"\";","sourceCodeStart":289,"sourceCodeEnd":325,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/ee/apps/den-web/app/(den)/dashboard/_components/org-dashboards-data.tsx#L289-L325","documentation":"useDashboardAccess fetches GET /v1/dashboards/:id/access and throws this error for any non-ok response when the payload lacks a specific message. The grants list cannot be loaded, so the access-management UI shows the query error state.","triggerScenarios":"Non-2xx from the access endpoint: 401 expired session, 403 caller lacks admin rights on the dashboard, 404 dashboard id invalid, 5xx from den-api while listing grants.","commonSituations":"Non-admin user opening the access panel; dashboard deleted in another tab; Den session cookie expired mid-session; API deployment in progress returning 502/503 from the gateway.","solutions":["Check the status code: 403 → confirm you have manage access on this dashboard, 401 → re-sign-in, 404 → verify the dashboard still exists, 5xx → inspect server logs","Reload the page to refresh the Den session and retry the query","Verify the dashboardId used by the hook matches an existing dashboard","If 5xx persists, check den-api logs for failures in the access-grant query path"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// only fetch access when the user can manage the dashboard\nif (!canManageDashboard(currentUser, dashboardId)) {\n  return; // skip the access query entirely\n}","typeGuard":null,"tryCatchPattern":"const { error, refetch } = useDashboardAccess(dashboardId);\nif (error instanceof Error) {\n  if (error.message.includes('(403)')) showNoManagePermission();\n  else showRetryBanner(error.message, refetch);\n}","preventionTips":["Gate the access panel behind a permission check so 403s are expected and handled","Distinguish 404 (dashboard gone) from 403 (no rights) from 5xx in the error UI","Retry with backoff only for 5xx and network errors","Alert on 5xx rates for the access endpoint in production"],"tags":["http","network","api","permissions"],"backgroundTag":"http-error-response","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}