different-ai/openwork · error

The dashboard response was invalid.

Error message

The dashboard response was invalid.

What it means

After a successful (ok) response, useManagedDashboard runs payload.item through parseDashboard; if the body is not an object or parseDashboard cannot build a valid ManagedDashboard, this error is thrown. It guards against a 200 response whose body violates the expected dashboard schema.

Source

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

}

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,
      );
      if (!response.ok) {
        throw new Error(getErrorMessage(payload, `Failed to load the dashboard (${response.status}).`));
      }
      const item = isRecord(payload) ? parseDashboard(payload.item) : null;
      if (!item) throw new Error("The dashboard response was invalid.");
      return item;
    },
  });
}

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,
        );

View on GitHub (pinned to 2b7df46e8a)

Solutions

  1. Log the raw payload and compare against the current parseDashboard field expectations
  2. Align frontend and den-api versions — a schema migration likely renamed or removed fields
  3. Hard-refresh / clear cache to rule out a stale service-worker or CDN response
  4. Add a field-by-field check for which required field parseDashboard rejected

Example fix

// before
const item = isRecord(payload) ? parseDashboard(payload.item) : null;
if (!item) throw new Error("The dashboard response was invalid.");
// after
const item = isRecord(payload) ? parseDashboard(payload.item) : null;
if (!item) {
  console.error('dashboard payload failed parseDashboard', payload);
  throw new Error("The dashboard response was invalid.");
}
Defensive patterns

Strategy: validation

Validate before calling

function looksLikeDashboard(payload: unknown): boolean {
  return isRecord(payload) && isRecord(payload.item) && typeof payload.item.id === 'string' && typeof payload.item.name === 'string';
}
// check before trusting data from the query

Type guard

const isDashboardItem = (p: unknown): p is { item: Record<string, unknown> } =>
  isRecord(p) && isRecord(p.item) && typeof (p.item as { id?: unknown }).id === 'string';

Try / catch

const { data, error } = useManagedDashboard(dashboardId);
if (error instanceof Error && error.message === 'The dashboard response was invalid.') {
  logSchemaMismatch('managed-dashboard', dashboardId);
  showFatalDataError();
}

Prevention

When it happens

Trigger: Server returned 200 with `{ item: null }`, an empty body, an unexpected field layout (renamed fields after an API change), or parseDashboard's required fields (e.g. id/name) missing or of the wrong type.

Common situations: Frontend/server version skew after a den-api deploy; CDN or service worker serving a cached/other response body; a test/stub server returning a placeholder payload.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


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