can1357/oh-my-pi · error
ssh://: exceeds the 1 MiB limit; ssh:// supports text files…
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.
Solutions
- Mount the host with sshfs and read the file through the local filesystem path instead
- Fetch a bounded portion via bash: `ssh prod 'head -n 1000 /var/log/big.log'` or `tail`
- 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
- Check remote file size (`stat -c %s`) before resolving large/log-like paths
- Prefer bash + head/tail for logs expected to grow past 1 MiB
- Use sshfs for anything that is not a small config/text file
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.
Understand the failure class
Background: "File too large" / "file size exceeds limit" errors: why libraries cap file sizes and how to fix them — this error's family across 46 libraries.
Related errors
- Archive is too large to read safely
- Cannot a remote ssh:// path (no local file): . Use \`read…
- Compress (.Z) output exceeds the
- error.message (ImageInputTooLargeError or…
- Failed to mount
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/a0713cd3995238e3.
Report an issue: GitHub.
Appendix: 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)