{"record":{"id":"a0713cd3995238e3","repo":"can1357/oh-my-pi","slug":"ssh-remotepath-exceeds-the-1-mib-limit-ssh","errorCode":null,"errorMessage":"ssh://: ${remotePath} exceeds the 1 MiB limit; ssh:// supports text files up to 1 MiB — use an sshfs mount for larger files","messagePattern":"ssh://: (.+?) exceeds the 1 MiB limit; ssh:// supports text files up to 1 MiB — use an sshfs mount for larger files","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/internal-urls/ssh-protocol.ts","lineNumber":300,"sourceCode":"\t\ttry {\n\t\t\tkind = await statRemotePath(target, remotePath, { signal: context?.signal });\n\t\t} catch {\n\t\t\t// stat failed (host/connection issue) — fall through; the read gives a clearer error.\n\t\t}\n\t\tif (kind === \"directory\") {\n\t\t\treturn this.#resolveDirectory(target, remotePath, url, context?.signal, context?.skipDirectoryListing);\n\t\t}\n\t\tif (kind === \"other\") {\n\t\t\tthrow new Error(\n\t\t\t\t`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`,\n\t\t\t);\n\t\t}\n\t\tconst fileResult = await readRemoteFile(target, remotePath, {\n\t\t\tmaxBytes: SSH_TEXT_MAX_BYTES,\n\t\t\tsignal: context?.signal,\n\t\t});\n\t\tif (fileResult.truncated) {\n\t\t\tthrow new Error(\n\t\t\t\t`ssh://: ${remotePath} exceeds the 1 MiB limit; ssh:// supports text files up to 1 MiB — use an sshfs mount for larger files`,\n\t\t\t);\n\t\t}\n\t\tconst content = decodeUtf8Text(fileResult.bytes);\n\t\tif (content === null) {\n\t\t\tthrow new Error(\n\t\t\t\t`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`,\n\t\t\t);\n\t\t}\n\t\t// No `sourcePath`: keeps search on the virtual-resource path so the\n\t\t// displayed/searched resource stays `ssh://…` instead of a temp path.\n\t\treturn {\n\t\t\turl: url.href,\n\t\t\tcontent,\n\t\t\tcontentType: contentTypeFor(remotePath),\n\t\t\tsize: fileResult.bytes.length,\n\t\t};\n\t}","sourceCodeStart":282,"sourceCodeEnd":318,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/internal-urls/ssh-protocol.ts#L282-L318","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nresolve('ssh://prod/var/log/huge.log') // > 1 MiB\n// after\nbash(\"ssh prod 'tail -n 500 /var/log/huge.log'\") // or sshfs-mount and read locally","handlingStrategy":"try-catch","validationCode":"const size = await remoteStatSize(target, remotePath); // stat -c %s\nif (size > 1024 * 1024) throw new Error(`${remotePath} is ${size} bytes; > 1 MiB — use sshfs or a ranged read`);","typeGuard":null,"tryCatchPattern":"try {\n  const res = await handler.resolve(url, ctx);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('exceeds the 1 MiB limit')) {\n    // switch to sshfs mount or bash `head`/`tail` for bounded reads\n  } else throw e;\n}","preventionTips":["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"],"tags":["ssh","file-size","limit-exceeded"],"backgroundTag":"file-size-limit-exceeded","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}