{"record":{"id":"9b4328f4c9394101","repo":"rtk-ai/rtk","slug":"stdin-exceeds-byte-limit","errorCode":null,"errorMessage":"stdin exceeds {} byte limit","messagePattern":"stdin exceeds (.+?) byte limit","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmds/system/pipe_cmd.rs","lineNumber":259,"sourceCode":"            eprintln!(\"[rtk] warning: filter panicked — passing through raw output\");\n            input.to_string()\n        })\n}\n\npub fn run(filter_name: Option<&str>, passthrough: bool) -> Result<()> {\n    if passthrough {\n        std::io::copy(&mut std::io::stdin(), &mut std::io::stdout())\n            .map_err(|e| anyhow::anyhow!(\"Failed to relay stdin: {}\", e))?;\n        return Ok(());\n    }\n\n    let mut buf = String::new();\n    std::io::stdin()\n        .take((RAW_CAP + 1) as u64)\n        .read_to_string(&mut buf)\n        .map_err(|e| anyhow::anyhow!(\"Failed to read stdin: {}\", e))?;\n    if buf.len() > RAW_CAP {\n        anyhow::bail!(\"stdin exceeds {} byte limit\", RAW_CAP);\n    }\n\n    let filter_fn = match filter_name {\n        Some(name) => resolve_filter(name).ok_or_else(|| {\n            anyhow::anyhow!(\n                \"Unknown filter '{}'. Available: cargo-test, pytest, go-test, go-build, \\\n                 tsc, vitest, grep, rg, find, fd, git-log, git-diff, git-status, \\\n                 log, mypy, ruff-check, ruff-format, prettier, phpunit, pest, \\\n                 paratest, php-test, ecs, phpstan, pint\",\n                name\n            )\n        })?,\n        None => auto_detect_filter(&buf),\n    };\n\n    let output = apply_filter(filter_fn, &buf);\n    let shown = never_worse(&buf, &output);\n    print!(\"{}\", shown);","sourceCodeStart":241,"sourceCodeEnd":277,"githubUrl":"https://github.com/rtk-ai/rtk/blob/d977e1c31621fe8704e6500ceeb9c7a0de2b6836/src/cmds/system/pipe_cmd.rs#L241-L277","documentation":"Filtered pipe mode caps captured stdin at RAW_CAP = 10_485_760 bytes (10 MiB, src/core/stream.rs:271). The reader takes RAW_CAP+1 bytes so oversize input is detected and rejected with a hard error rather than silently truncating a filter mid-line. Passthrough mode (`--passthrough`) uses io::copy and has no cap.","triggerScenarios":"Feeding more than 10 MiB into `rtk pipe` or `rtk pipe --filter cargo-test`: `cat monorepo-test.log | rtk pipe` with a 40 MiB log; `rtk git diff | ...` chains that accumulate; verbose CI/e2e dumps. The error fires exactly when buf.len() > 10485760.","commonSituations":"Monorepo test/build logs with debug verbosity; Playwright/Cypress full traces; `git log -p` over long histories piped raw; combining several logs with cat before rtk pipe.","solutions":["Trim upstream: `tail -c 10485760 huge.log | rtk pipe` or pre-filter: `grep -E 'FAIL|^error' huge.log | rtk pipe`","Use uncapped passthrough when you need everything: `cat huge.log | rtk pipe --passthrough`","Reduce verbosity at the source (test reporters, log levels) or split the stream per module/file"],"exampleFix":"# before: 40 MiB log -> \"stdin exceeds 10485760 byte limit\"\ncat all-tests.log | rtk pipe\n\n# after\ntail -c 10485760 all-tests.log | rtk pipe      # last 10 MiB\ncat all-tests.log | rtk pipe --passthrough     # no cap, unfiltered\ngrep -E 'FAILED|^error' all-tests.log | rtk pipe","handlingStrategy":"validation","validationCode":"bash:\nCAP=10485760  # RAW_CAP = 10 MiB (src/core/stream.rs)\nSIZE=$(wc -c < input.log)\nif [ \"$SIZE\" -gt \"$CAP\" ]; then\n  tail -c \"$CAP\" input.log | rtk pipe      # or: rtk pipe --passthrough < input.log\nelse\n  rtk pipe < input.log\nfi","typeGuard":null,"tryCatchPattern":"bash:\nrtk pipe < input.log 2>err.txt || {\n  grep -q 'stdin exceeds' err.txt && { tail -c 10485760 input.log | rtk pipe; }\n} || rtk pipe --passthrough < input.log","preventionTips":["Know the cap: 10 MiB (10_485_760 bytes) for filtered pipe mode; passthrough has none","Pre-trim logs with tail/grep so rtk sees the useful tail, not the whole history","Split monorepo logs per crate/module before filtering","Lower upstream verbosity (reporter modes, --quiet) instead of shipping raw dumps"],"tags":["stdin","limits","pipe","memory","usage"],"backgroundTag":null,"analyzedSha":"d977e1c31621fe8704e6500ceeb9c7a0de2b6836","analyzedAt":"2026-08-16T05:40:46.291Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}