different-ai/openwork · error

Failed to load dashboards (${response.status}).

Error message

Failed to load dashboards (${response.status}).

What it means

useManagedDashboards fetches GET /v1/dashboards via requestJson and throws this error when the HTTP response is not ok and the payload carries no more specific message (getErrorMessage falls back to this template). It is a generic HTTP-failure wrapper that embeds the status code.

Source

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

  return {
    ...element,
    connectionId: element.connectionId,
    description: readString(value.description),
    requiresInput: value.requiresInput === true,
    requiresApproval: value.requiresApproval === true,
  };
}

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

export function useManagedDashboard(dashboardId: string) {
  const { orgContext } = useOrgDashboard();
  const organizationId = orgContext?.organization.id ?? "";
  return useQuery({
    enabled: Boolean(organizationId && dashboardId),
    queryKey: orgDashboardsQueryKeys.detail(organizationId, dashboardId),
    queryFn: async (): Promise<ManagedDashboard> => {
      const { response, payload } = await requestJson(
        `/v1/dashboards/${encodeURIComponent(dashboardId)}`,
        { method: "GET" },
        15000,

View on GitHub (pinned to 2b7df46e8a)

Solutions

  1. Read the status code in the message: 401 → re-authenticate, 403 → request org permissions, 404 → check API base URL/version, 5xx → check server logs
  2. Refresh the page / re-sign-in to renew the Den session
  3. Confirm the app is pointed at the correct den-api base URL for the environment
  4. If 5xx persists, check den-api server logs and dashboards table health

Example fix

// before
if (!response.ok) {
  throw new Error(getErrorMessage(payload, `Failed to load dashboards (${response.status}).`));
}
// after
if (!response.ok) {
  if (response.status === 401) await reauthenticate();
  throw new Error(getErrorMessage(payload, `Failed to load dashboards (${response.status}).`));
}
Defensive patterns

Strategy: try-catch

Validate before calling

// pre-flight session check before mounting queries
const session = await fetch('/v1/session', { method: 'GET' });
if (!session.ok) { redirectToSignIn(); }

Try / catch

const { isLoading, error } = useManagedDashboards(organizationId);
if (error) {
  const msg = error instanceof Error ? error.message : 'Unknown error';
  if (msg.includes('(401)')) redirectToSignIn();
  else if (msg.includes('(403)')) showNoPermission();
  else showRetryBanner(msg, () => refetch());
}

Prevention

When it happens

Trigger: Any non-2xx status from GET /v1/dashboards: 401 (expired Den session), 403 (not an org member), 404 (wrong API base path), 5xx (server error), or a 15s timeout path producing a non-ok response.

Common situations: Session cookie expired after idle; user's role lacks dashboard read permission; self-hosted server version without the /v1/dashboards route; Den API pod crashing under load.

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/b8d0928374848cfd. Report an issue: GitHub.