{"record":{"id":"771b27994f73428e","repo":"paperclipai/paperclip","slug":"unsupported-storage-response-body","errorCode":null,"errorMessage":"Unsupported storage response body.","messagePattern":"Unsupported storage response body\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cli/src/commands/worktree.ts","lineNumber":347,"sourceCode":"    transformToWebStream?: () => ReadableStream<Uint8Array>;\n    arrayBuffer?: () => Promise<ArrayBuffer>;\n  };\n  if (typeof candidate.transformToWebStream === \"function\") {\n    const webStream = candidate.transformToWebStream();\n    const reader = webStream.getReader();\n    const chunks: Uint8Array[] = [];\n    while (true) {\n      const { done, value } = await reader.read();\n      if (done) break;\n      if (value) chunks.push(value);\n    }\n    return Buffer.concat(chunks.map((chunk) => Buffer.from(chunk)));\n  }\n  if (typeof candidate.arrayBuffer === \"function\") {\n    return Buffer.from(await candidate.arrayBuffer());\n  }\n\n  throw new Error(\"Unsupported storage response body.\");\n}\n\nfunction normalizeS3Prefix(prefix: string | undefined): string {\n  if (!prefix) return \"\";\n  return prefix.trim().replace(/^\\/+/, \"\").replace(/\\/+$/, \"\");\n}\n\nfunction buildS3ObjectKey(prefix: string, objectKey: string): string {\n  return prefix ? `${prefix}/${objectKey}` : objectKey;\n}\n\nconst dynamicImport = new Function(\"specifier\", \"return import(specifier);\") as (specifier: string) => Promise<any>;\n\nfunction createConfiguredStorageFromPaperclipConfig(config: PaperclipConfig): ConfiguredStorage {\n  if (config.storage.provider === \"local_disk\") {\n    const baseDir = expandHomePrefix(config.storage.localDisk.baseDir);\n    return {\n      async getObject(companyId: string, objectKey: string) {","sourceCodeStart":329,"sourceCodeEnd":365,"githubUrl":"https://github.com/paperclipai/paperclip/blob/67001ec6eb96ae601aa27bc91d9b2415d665334a/cli/src/commands/worktree.ts#L329-L365","documentation":"Thrown by s3BodyToBuffer when the storage response body is a non-empty object but exposes none of the supported consumption interfaces: it is not a Buffer, not a Node Readable stream, and has neither transformToWebStream nor arrayBuffer methods. The helper cannot materialize bytes from it.","triggerScenarios":"Using an @aws-sdk/client-s3 version whose response Body type differs (e.g. a newer SDK returning a different streaming primitive); mocking S3 responses with a plain object or string body; an S3-compatible vendor SDK that wraps responses in an unsupported shape; runtime where Readable cross-realm instanceof checks fail.","commonSituations":"Major @aws-sdk/client-s3 version upgrade changing the Body payload contract; polyfilled streams where instanceof Readable is unreliable across module realms; returning a string or TypedArray directly from a test double.","solutions":["Pin or upgrade @aws-sdk/client-s3 to a version whose Body is a Node Readable or has transformToWebStream/arrayBuffer.","In tests, return a Readable.from(Buffer) or an object exposing arrayBuffer()/transformToWebStream() rather than a plain object.","If using a custom S3-compatible client adapter, normalize its Body to one of the supported shapes before returning.","Check for duplicate/incompatible @aws-sdk versions in node_modules (pnpm why @aws-sdk/client-s3)."],"exampleFix":"// before (test mock)\ngetObject: async () => ({ Body: { data: 'hi' } })\n// after\ngetObject: async () => ({ Body: Readable.from(Buffer.from('hi')) })","handlingStrategy":"type-guard","validationCode":"function isConsumableBody(body: unknown): boolean {\n  return !!body && (\n    Buffer.isBuffer(body) ||\n    body instanceof Readable ||\n    typeof (body as any)?.transformToWebStream === 'function' ||\n    typeof (body as any)?.arrayBuffer === 'function'\n  );\n}","typeGuard":"function isSupportedBody(body: unknown): body is Buffer | Readable | { transformToWebStream(): ReadableStream<Uint8Array> } | { arrayBuffer(): Promise<ArrayBuffer> } {\n  return isConsumableBody(body);\n}","tryCatchPattern":"try {\n  return await s3BodyToBuffer(resp.Body);\n} catch (e) {\n  if (e instanceof Error && e.message === 'Unsupported storage response body.') {\n    throw new Error('S3 SDK version mismatch: update @aws-sdk/client-s3');\n  }\n  throw e;\n}","preventionTips":["Pin @aws-sdk/client-s3 to a tested major version.","In tests, return Readable.from(Buffer) or an object with arrayBuffer().","Check for duplicate @aws-sdk copies with pnpm why."],"tags":["storage","s3","streaming","version-mismatch","serialization"],"backgroundTag":null,"analyzedSha":"67001ec6eb96ae601aa27bc91d9b2415d665334a","analyzedAt":"2026-08-12T12:05:45.408Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}