paperclipai/paperclip · error · Error

API error

Error message

API error ${response.status}: ${message}

What it means

parseFetchResponse re-throws a non-OK attachment download response, extracting the server's JSON error message if present; the guard fires for any failed raw fetch to the attachments content endpoint.

Solutions

  1. Read the API error message in the output, fix the request (parameters/permissions), and retry.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at cli/src/commands/client/issue.ts:1439 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of paperclipai/paperclip@3f1d897a7c (2026-08-18). Data as JSON: /api/errors/5c9140a226c3cdbd. Report an issue: GitHub.

Appendix: source

Thrown at cli/src/commands/client/issue.ts:1445

): Promise<Buffer> {
  const response = await fetch(buildApiUrl(apiBase, apiPath`/api/attachments/${attachmentId}/content`), {
    headers: apiKey ? { authorization: `Bearer ${apiKey}` } : undefined,
  });
  if (!response.ok) {
    await parseFetchResponse(response);
  }
  return Buffer.from(await response.arrayBuffer());
}

async function parseFetchResponse(response: Response): Promise<unknown> {
  const text = await response.text();
  const parsed = text.trim() ? safeJson(text) : null;
  if (!response.ok) {
    const message =
      typeof parsed === "object" && parsed !== null && "error" in parsed && typeof parsed.error === "string"
        ? parsed.error
        : `Request failed with status ${response.status}`;
    throw new Error(`API error ${response.status}: ${message}`);
  }
  return parsed;
}

function safeJson(text: string): unknown {
  try {
    return JSON.parse(text) as unknown;
  } catch {
    return text;
  }
}

View on GitHub (pinned to 3f1d897a7c)