rtk-ai/rtk · error
stdin exceeds byte limit
Error message
stdin exceeds {} byte limit What it means
`rtk pipe` reads stdin up to a hard cap of RAW_CAP (10 MiB, from src/core/stream.rs). It reads RAW_CAP+1 bytes so it can detect overflow; if more than 10 MiB arrives, it bails instead of silently truncating, protecting the LLM context window from unbounded input.
Solutions
- Reduce input before piping: `cat huge.log | grep ERROR | rtk pipe` or `... | tail -n 10000 | rtk pipe`.
- Apply a named filter so rtk compresses at the source: `cargo test 2>&1 | rtk pipe --filter cargo-test` where possible instead of piping raw output.
- Split or rotate the oversized input and process it in chunks under 10 MiB.
- Use `rtk proxy <cmd>` or run the command directly if you need the full raw output (bypassing the cap) — at the cost of token usage.
Example fix
// before cat build.log | rtk pipe # build.log is 40 MiB -> exceeds 10 MiB cap // after grep -E 'ERROR|WARN' build.log | rtk pipe # or: tail -c 10M build.log | rtk pipe
Defensive patterns
Strategy: validation
Validate before calling
const MAX = 10 * 1024 * 1024; // RAW_CAP = 10_485_760 bytes
const stat = fs.fstatSync(0);
if (stat.size > MAX) throw new Error(`stdin exceeds ${MAX} byte limit; filter or truncate first`); Type guard
fn within_cap(len: usize, cap: usize = 10_485_760) -> bool { len <= cap } Try / catch
match rtk_pipe_result {
Err(e) if e.to_string().contains("stdin exceeds") => {
eprintln!("input too large; pipe through grep/head/tail or use --filter before rtk pipe");
std::process::exit(1);
}
other => other?,
} Prevention
- Pre-filter stdin (grep, head, tail, awk) before `rtk pipe` for large logs.
- Use a named --filter (cargo-test, pytest, go-test, ...) so rtk compresses at the source.
- Check file size (`du -h` / fstat) of piped artifacts in CI before invoking rtk pipe.
- For genuinely huge output, bypass with `rtk proxy` only when full fidelity is required.
When it happens
Trigger: Piping more than 10 MiB into `rtk pipe` (e.g. `cat huge.log | rtk pipe`), with or without a --filter name; any invocation of pipe_cmd::run whose stdin exceeds RAW_CAP bytes.
Common situations: Piping full build logs, large test suite output, or database dumps; forgetting an upstream filter (grep/head) on a chatty command; CI artifacts streamed whole instead of summarized.
Understand the failure class
Background: payload too large / request exceeds maximum size: why libraries cap bytes and how to fix oversize payloads — this error's family across 50 libraries.
Related errors
- Failed to read stdin
- Failed to relay stdin
- hook stdin exceeds byte limit
- ambiguous hash prefix
- Antigravity is project-scoped. Use: rtk init --agent…
AI-assisted analysis of rtk-ai/rtk@0924356b4c (2026-09-19).
Data as JSON: /api/errors/9b4328f4c9394101.
Report an issue: GitHub.
Appendix: source
Thrown at src/cmds/system/pipe_cmd.rs:269
input.to_string()
},
)
}
pub fn run(filter_name: Option<&str>, passthrough: bool) -> Result<()> {
if passthrough {
std::io::copy(&mut std::io::stdin(), &mut std::io::stdout())
.map_err(|e| anyhow::anyhow!("Failed to relay stdin: {}", e))?;
return Ok(());
}
let mut buf = String::new();
std::io::stdin()
.take((RAW_CAP + 1) as u64)
.read_to_string(&mut buf)
.map_err(|e| anyhow::anyhow!("Failed to read stdin: {}", e))?;
if buf.len() > RAW_CAP {
anyhow::bail!("stdin exceeds {} byte limit", RAW_CAP);
}
let filter_fn = match filter_name {
Some(name) => resolve_filter(name).ok_or_else(|| {
anyhow::anyhow!(
"Unknown filter '{}'. Available: cargo-test, pytest, go-test, go-build, \
ctest, tsc, vitest, grep, rg, find, fd, git-log, git-diff, git-status, \
log, mypy, ruff-check, ruff-format, sqlfluff-lint, prettier, phpunit, pest, \
paratest, php-test, ecs, phpstan, pint",
name
)
})?,
None => auto_detect_filter(&buf),
};
let output = apply_filter(filter_fn, &buf);
let shown = never_worse(&buf, &output);
print!("{}", shown);View on GitHub (pinned to 0924356b4c)