{"record":{"id":"881d00ee4bba2b58","repo":"paperclipai/paperclip","slug":"remote-file-read-was-truncated-for-remotepath","errorCode":null,"errorMessage":"Remote file read was truncated for ${remotePath}: ${out.byteLength}/${totalBytes} bytes","messagePattern":"Remote file read was truncated for (.+?): (.+?)/(.+?) bytes","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/adapter-utils/src/command-managed-runtime.ts","lineNumber":385,"sourceCode":"      // single base64 stdout string for the whole archive. The client API still\n      // returns the decoded file as a Buffer, but every command result stays\n      // small enough for provider-backed sandbox RPCs.\n      const decodedChunks: Buffer[] = [];\n      let decodedSoFar = 0;\n      if (totalBytes === 0) {\n        await options?.onProgress?.(0, 0);\n        return Buffer.alloc(0);\n      }\n      for (let chunkIndex = 0; decodedSoFar < totalBytes; chunkIndex++) {\n        const result = await runShell(\n          `dd if=${shellQuote(remotePath)} bs=${REMOTE_READ_CHUNK_BYTES} skip=${chunkIndex} count=1 2>/dev/null | base64`,\n        );\n        const chunk = Buffer.from(result.stdout.replace(/\\s+/g, \"\"), \"base64\");\n        if (chunk.byteLength === 0) break;\n        decodedChunks.push(chunk);\n        decodedSoFar += chunk.byteLength;\n        await options?.onProgress?.(Math.min(decodedSoFar, totalBytes), totalBytes);\n      }\n      const out = Buffer.concat(decodedChunks);\n      if (out.byteLength !== totalBytes) {\n        throw new Error(`Remote file read was truncated for ${remotePath}: ${out.byteLength}/${totalBytes} bytes`);\n      }\n      await options?.onProgress?.(out.byteLength, totalBytes);\n      return out;\n    },\n    listFiles: async (remotePath) => {\n      const result = await runShell(\n        `if [ -d ${shellQuote(remotePath)} ]; then ` +\n          `for entry in ${shellQuote(remotePath)}/*; do ` +\n          `[ -f \"$entry\" ] || continue; ` +\n          `basename \"$entry\"; ` +\n          `done; ` +\n        `fi`,\n      );\n      return result.stdout\n        .split(/\\r?\\n/)","sourceCodeStart":367,"sourceCodeEnd":403,"githubUrl":"https://github.com/paperclipai/paperclip/blob/3f1d897a7c018d76563a21c6e39c3c9b03933622/packages/adapter-utils/src/command-managed-runtime.ts#L367-L403","documentation":"Read-integrity check in the command-managed client: a chunked remote file read (dd+base64 per chunk) decoded fewer bytes than the file's reported total, meaning the transfer was cut short mid-stream; retrying the read is the correct response.","triggerScenarios":"Thrown at packages/adapter-utils/src/command-managed-runtime.ts:315 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry the operation; the remote read was cut short.","Check for truncated writes on the remote target (disk full, connection drops)."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3f1d897a7c018d76563a21c6e39c3c9b03933622","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}