can1357/oh-my-pi · error

ssh://: ${remotePath} exceeds the 1 MiB limit; ssh:// suppor

Error message

ssh://: ${remotePath} exceeds the 1 MiB limit; ssh:// supports text files up to 1 MiB — use an sshfs mount for larger files

What it means

ssh:// materializes remote files into memory with a hard cap of 1 MiB (`SSH_TEXT_MAX_BYTES`). `readRemoteFile` reports `truncated` when the file exceeds that cap, and the handler turns that into an explicit error rather than returning clipped content, which would silently mislead tools reading the file.

Source

Thrown at packages/coding-agent/src/internal-urls/ssh-protocol.ts:300

		try {
			kind = await statRemotePath(target, remotePath, { signal: context?.signal });
		} catch {
			// stat failed (host/connection issue) — fall through; the read gives a clearer error.
		}
		if (kind === "directory") {
			return this.#resolveDirectory(target, remotePath, url, context?.signal, context?.skipDirectoryListing);
		}
		if (kind === "other") {
			throw new Error(
				`ssh://: ${remotePath} is not a regular file (FIFO, socket, or device); ssh:// reads UTF-8 text files only — use \`bash\` with a remote SSH command for special files`,
			);
		}
		const fileResult = await readRemoteFile(target, remotePath, {
			maxBytes: SSH_TEXT_MAX_BYTES,
			signal: context?.signal,
		});
		if (fileResult.truncated) {
			throw new Error(
				`ssh://: ${remotePath} exceeds the 1 MiB limit; ssh:// supports text files up to 1 MiB — use an sshfs mount for larger files`,
			);
		}
		const content = decodeUtf8Text(fileResult.bytes);
		if (content === null) {
			throw new Error(
				`ssh://: ${remotePath} is a binary or non-UTF-8 file; ssh:// supports UTF-8 text only — use \`bash\` with a remote SSH command or an \`sshfs\` mount`,
			);
		}
		// No `sourcePath`: keeps search on the virtual-resource path so the
		// displayed/searched resource stays `ssh://…` instead of a temp path.
		return {
			url: url.href,
			content,
			contentType: contentTypeFor(remotePath),
			size: fileResult.bytes.length,
		};
	}

View on GitHub (pinned to 9690622007)

Solutions

  1. Mount the host with sshfs and read the file through the local filesystem path instead
  2. Fetch a bounded portion via bash: `ssh prod 'head -n 1000 /var/log/big.log'` or `tail`
  3. Compress/split or trim the remote file, or exclude it from ssh://-based reads

Example fix

// before
resolve('ssh://prod/var/log/huge.log') // > 1 MiB
// after
bash("ssh prod 'tail -n 500 /var/log/huge.log'") // or sshfs-mount and read locally
Defensive patterns

Strategy: try-catch

Validate before calling

const size = await remoteStatSize(target, remotePath); // stat -c %s
if (size > 1024 * 1024) throw new Error(`${remotePath} is ${size} bytes; > 1 MiB — use sshfs or a ranged read`);

Try / catch

try {
  const res = await handler.resolve(url, ctx);
} catch (e) {
  if (e instanceof Error && e.message.includes('exceeds the 1 MiB limit')) {
    // switch to sshfs mount or bash `head`/`tail` for bounded reads
  } else throw e;
}

Prevention

When it happens

Trigger: Resolving an ssh:// URL whose remote file is larger than 1 MiB so `readRemoteFile` returns `fileResult.truncated === true`, e.g. a multi-megabyte log or dataset.

Common situations: Reading large logs, CSVs, or binary-adjacent data dumps over ssh://; files that grew past the cap since they were last read; trying to use ssh:// as a general file transfer.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/a0713cd3995238e3. Report an issue: GitHub.