{"record":{"id":"0a7acd69ae026f78","repo":"paperclipai/paperclip","slug":"cloud-portfolio-invalid-response","errorCode":"cloud_portfolio_invalid_response","errorMessage":"Paperclip Cloud portfolio returned invalid JSON","messagePattern":"Paperclip Cloud portfolio returned invalid JSON","errorType":"http","errorClass":"HttpError","httpStatus":502,"severity":"error","filePath":"server/src/routes/cloud.ts","lineNumber":95,"sourceCode":"          \"x-paperclip-cloud-stack-id\": context.stackId,\n        },\n        signal: AbortSignal.timeout(10_000),\n      });\n      if (!upstream.ok) {\n        logger.warn(\n          { status: upstream.status, stackId: context.stackId },\n          \"Paperclip Cloud portfolio request failed\",\n        );\n        throw new HttpError(502, \"Paperclip Cloud portfolio request failed\", {\n          code: \"cloud_portfolio_upstream_error\",\n        });\n      }\n\n      let payload: unknown;\n      try {\n        payload = await upstream.json();\n      } catch {\n        throw new HttpError(502, \"Paperclip Cloud portfolio returned invalid JSON\", {\n          code: \"cloud_portfolio_invalid_response\",\n        });\n      }\n      portfolioCache.set(cacheKey, {\n        expiresAt: currentTime + cacheTtlMs,\n        payload,\n      });\n      res.setHeader(\"Cache-Control\", \"no-store\");\n      res.json(payload);\n    } catch (error) {\n      if (error instanceof HttpError) throw error;\n      logger.warn(\n        { err: error, stackId: context.stackId },\n        \"Paperclip Cloud portfolio request failed\",\n      );\n      throw new HttpError(502, \"Paperclip Cloud portfolio request failed\", {\n        code: \"cloud_portfolio_upstream_error\",\n      });","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/paperclipai/paperclip/blob/120ae5428fa29bee300bcf806491cd4d965fbb7c/server/src/routes/cloud.ts#L77-L113","documentation":"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.","triggerScenarios":"Thrown at server/src/routes/cloud.ts:95 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry the request; if it persists, verify the Paperclip Cloud endpoint version matches this server."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"120ae5428fa29bee300bcf806491cd4d965fbb7c","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}