paperclipai/paperclip · error · HttpError
cloud_portfolio_invalid_response
cloud_portfolio_invalid_response
Error message
Paperclip Cloud portfolio returned invalid JSON
What it means
Payload decode failure in the /stacks route: the upstream portfolio request succeeded but upstream.json() threw, so the response body is not valid JSON. Wrapped into HTTP 502 because the bad payload originates upstream.
Source
Thrown at server/src/routes/cloud.ts:95
"x-paperclip-cloud-stack-id": context.stackId,
},
signal: AbortSignal.timeout(10_000),
});
if (!upstream.ok) {
logger.warn(
{ status: upstream.status, stackId: context.stackId },
"Paperclip Cloud portfolio request failed",
);
throw new HttpError(502, "Paperclip Cloud portfolio request failed", {
code: "cloud_portfolio_upstream_error",
});
}
let payload: unknown;
try {
payload = await upstream.json();
} catch {
throw new HttpError(502, "Paperclip Cloud portfolio returned invalid JSON", {
code: "cloud_portfolio_invalid_response",
});
}
portfolioCache.set(cacheKey, {
expiresAt: currentTime + cacheTtlMs,
payload,
});
res.setHeader("Cache-Control", "no-store");
res.json(payload);
} catch (error) {
if (error instanceof HttpError) throw error;
logger.warn(
{ err: error, stackId: context.stackId },
"Paperclip Cloud portfolio request failed",
);
throw new HttpError(502, "Paperclip Cloud portfolio request failed", {
code: "cloud_portfolio_upstream_error",
});View on GitHub (pinned to 120ae5428f)
Solutions
- Retry the request; if it persists, verify the Paperclip Cloud endpoint version matches this server.
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at server/src/routes/cloud.ts:95 when the library encounters an invalid state.
Common situations: See trigger scenarios.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
AI-assisted analysis of paperclipai/paperclip@120ae5428f (2026-08-18).
Data as JSON: /api/errors/0a7acd69ae026f78.
Report an issue: GitHub.