different-ai/openwork · error

Failed to load dashboard access (${response.status}).

Error message

Failed to load dashboard access (${response.status}).

What it means

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.

Source

Thrown at ee/apps/den-web/app/(den)/dashboard/_components/org-dashboards-data.tsx:307

      queryClient.invalidateQueries({ queryKey: orgDashboardsQueryKeys.list(organizationId) });
    },
  });
}

export function useDashboardAccess(dashboardId: string) {
  const { orgContext } = useOrgDashboard();
  const organizationId = orgContext?.organization.id ?? "";
  return useQuery({
    enabled: Boolean(organizationId && dashboardId),
    queryKey: orgDashboardsQueryKeys.access(organizationId, dashboardId),
    queryFn: async (): Promise<DashboardAccessGrant[]> => {
      const { response, payload } = await requestJson(
        `/v1/dashboards/${encodeURIComponent(dashboardId)}/access`,
        { method: "GET" },
        15000,
      );
      if (!response.ok) {
        throw new Error(getErrorMessage(payload, `Failed to load dashboard access (${response.status}).`));
      }
      const items = isRecord(payload) && Array.isArray(payload.items) ? payload.items : [];
      return items
        .map(parseAccessGrant)
        .filter((grant): grant is DashboardAccessGrant => grant !== null && grant.removedAt === null);
    },
  });
}

type GrantDashboardAccessBody =
  | { orgMembershipId: string; teamId?: never; orgWide?: never; role: DashboardAccessRole }
  | { orgMembershipId?: never; teamId: string; orgWide?: never; role: DashboardAccessRole }
  | { orgMembershipId?: never; teamId?: never; orgWide: true; role: DashboardAccessRole };

export function useGrantDashboardAccess() {
  const queryClient = useQueryClient();
  const { orgContext, runReauthableAction } = useOrgDashboard();
  const organizationId = orgContext?.organization.id ?? "";

View on GitHub (pinned to 2b7df46e8a)

Solutions

  1. 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
  2. Reload the page to refresh the Den session and retry the query
  3. Verify the dashboardId used by the hook matches an existing dashboard
  4. If 5xx persists, check den-api logs for failures in the access-grant query path
Defensive patterns

Strategy: try-catch

Validate before calling

// only fetch access when the user can manage the dashboard
if (!canManageDashboard(currentUser, dashboardId)) {
  return; // skip the access query entirely
}

Try / catch

const { error, refetch } = useDashboardAccess(dashboardId);
if (error instanceof Error) {
  if (error.message.includes('(403)')) showNoManagePermission();
  else showRetryBanner(error.message, refetch);
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.

Related errors


AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01). Data as JSON: /api/errors/f86f9ad84a29d3bb. Report an issue: GitHub.