paperclipai/paperclip · error

Could not determine remote file size for

Error message

Could not determine remote file size for ${remotePath}

What it means

Pre-flight check in the command-managed client's writeFile path: the remote target's size could not be determined (stat/ls probe failed or returned nothing) before attempting a chunked or atomic remote write, so the write strategy cannot be chosen safely.

Solutions

  1. Verify the remote file ${remotePath} exists and is readable, then retry.
  2. Check sandbox connectivity and permissions on the remote path.
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at packages/adapter-utils/src/command-managed-runtime.ts:290 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at packages/adapter-utils/src/command-managed-runtime.ts:363

        // Shell-backed sandbox reads need the same absent-file contract as fs.
        // Confirm the parent is searchable so permission/transport failures are
        // never silently converted into a missing optional credential file.
        const parent = shellQuote(path.posix.dirname(remotePath));
        const missing = await runShell(
          `if [ -d ${parent} ] && [ -x ${parent} ] && [ ! -e ${shellQuote(remotePath)} ]; ` +
            `then printf 'missing'; fi`,
        ).catch(() => null);
        if (missing?.stdout === "missing") {
          throw Object.assign(new Error(`No such file: ${remotePath}`), {
            code: "ENOENT",
            path: remotePath,
          });
        }
        throw error;
      }
      const totalBytes = Number.parseInt(sizeResult.stdout.trim(), 10);
      if (!Number.isFinite(totalBytes) || totalBytes < 0) {
        throw new Error(`Could not determine remote file size for ${remotePath}`);
      }

      // Read in bounded remote chunks so the runner never has to materialize a
      // single base64 stdout string for the whole archive. The client API still
      // returns the decoded file as a Buffer, but every command result stays
      // small enough for provider-backed sandbox RPCs.
      const decodedChunks: Buffer[] = [];
      let decodedSoFar = 0;
      if (totalBytes === 0) {
        await options?.onProgress?.(0, 0);
        return Buffer.alloc(0);
      }
      for (let chunkIndex = 0; decodedSoFar < totalBytes; chunkIndex++) {
        const result = await runShell(
          `dd if=${shellQuote(remotePath)} bs=${REMOTE_READ_CHUNK_BYTES} skip=${chunkIndex} count=1 2>/dev/null | base64`,
        );
        const chunk = Buffer.from(result.stdout.replace(/\s+/g, ""), "base64");
        if (chunk.byteLength === 0) break;

View on GitHub (pinned to 3f1d897a7c)