paperclipai/paperclip · error

${body?.error ?? `Export failed: ${res.status}`}

Error message

${body?.error ?? `Export failed: ${res.status}`}

What it means

The UI audit export API client performs tenant-session recovery on failed responses; if recovery does not apply, it throws an Error whose message is the server-provided body.error string, or a synthesized 'Export failed: <status>' when the body has no error field.

Source

Thrown at ui/src/api/audit.ts:117

   * Fetch the filtered feed as a CSV blob. The server logs an `audit.exported`
   * activity row for the export itself (training-data export precedent).
   */
  exportAgentActionsCsv: async (
    companyId: string,
    filters: Omit<AuditActionFilters, "cursor" | "limit"> = {},
  ): Promise<Blob> => {
    const search = buildAuditQuery(filters);
    const qs = search.toString();
    const res = await fetch(
      `/api/companies/${companyId}/audit/agent-actions.csv${qs ? `?${qs}` : ""}`,
      { credentials: "include", headers: { Accept: "text/csv" } },
    );
    if (!res.ok) {
      const body = await res.json().catch(() => null);
      const recovery = tenantSessionRecovery.recoverIfNeeded(res.status, body);
      if (recovery) return recovery;
      const message = (body as { error?: string } | null)?.error ?? `Export failed: ${res.status}`;
      throw new Error(message);
    }
    return res.blob();
  },
};

View on GitHub (pinned to 01ad858492)

Solutions

  1. Check the thrown message/body.error for the server's specific cause and fix that (permissions, date range size)
  2. Re-authenticate: log in again or refresh the tenant session if status was 401
  3. Retry with a smaller date range / narrower filters if the export is timing out or too large

Example fix

// before
await exportAuditLog({ range: 'all' });
// after: narrow the export window
await exportAuditLog({ from: lastWeek, to: today });
Defensive patterns

Strategy: try-catch

Validate before calling

if (!res.ok) { const body = await res.json().catch(() => null); console.error('Export failed', res.status, body?.error); }

Try / catch

try { const blob = await auditApi.export(params); } catch (e) { if (e.message.includes('Export failed')) { showToast(`Audit export unavailable: ${e.message}`); } else throw e; }

Prevention

When it happens

Trigger: The audit export fetch resolves but res.ok is false (4xx/5xx from /api audit export endpoint), and tenantSessionRecovery.recoverIfNeeded returns falsy.

Common situations: Session lacks permission for the audit scope (403), export range too large (500/413), tenant session expired on a multi-tenant deployment not handled by recovery, transient server error during export.

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 paperclipai/paperclip@01ad858492 (2026-09-10). Data as JSON: /api/errors/1c963ed95b06ba76. Report an issue: GitHub.