{"record":{"id":"03506b97b870db3d","repo":"Hmbown/CodeWhale","slug":"stdin-bundle-exceeds-the-max-bundle-bytes-byte-limit-refused","errorCode":null,"errorMessage":"stdin bundle exceeds the {MAX_BUNDLE_BYTES} byte limit; refused","messagePattern":"stdin bundle exceeds the (.+?) byte limit; refused","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/cli/src/config_bundles.rs","lineNumber":1513,"sourceCode":"    };\n    validate_scope_target(scope, store.path())?;\n    let remote_source = args.source.starts_with(\"https://\") || args.source.starts_with(\"http://\");\n    let source_label = if args.source == \"-\" {\n        \"stdin\"\n    } else if remote_source {\n        \"remote bundle\"\n    } else {\n        args.source.as_str()\n    };\n    let raw = if args.source == \"-\" {\n        let mut buffer = Vec::new();\n        std::io::stdin()\n            .lock()\n            .take(MAX_BUNDLE_BYTES + 1)\n            .read_to_end(&mut buffer)\n            .context(\"reading bundle from stdin\")?;\n        if buffer.len() as u64 > MAX_BUNDLE_BYTES {\n            bail!(\"stdin bundle exceeds the {MAX_BUNDLE_BYTES} byte limit; refused\");\n        }\n        buffer\n    } else if remote_source {\n        fetch_bundle(&args.source)?\n    } else {\n        let path = PathBuf::from(&args.source);\n        let metadata = std::fs::metadata(&path)\n            .with_context(|| format!(\"reading bundle at {}\", path.display()))?;\n        if metadata.len() > MAX_BUNDLE_BYTES {\n            bail!(\n                \"bundle at {} is {} bytes; the limit is {MAX_BUNDLE_BYTES} bytes\",\n                path.display(),\n                metadata.len()\n            );\n        }\n        std::fs::read(&path).with_context(|| format!(\"reading bundle at {}\", path.display()))?\n    };\n","sourceCodeStart":1495,"sourceCodeEnd":1531,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/cli/src/config_bundles.rs#L1495-L1531","documentation":"When a bundle is read from stdin, the reader is capped at MAX_BUNDLE_BYTES + 1 via take(); if more than MAX_BUNDLE_BYTES bytes arrive, the source is treated as invalid and refused rather than truncated. This protects the parser and memory from oversized or pathological input.","triggerScenarios":"Piping a bundle into `config import -` (stdin source) where the stream is larger than MAX_BUNDLE_BYTES bytes.","commonSituations":"Piping concatenated or minified dumps into stdin by mistake; curl | import against a URL serving a huge file; accidentally piping a binary artifact or log instead of the TOML bundle.","solutions":["Inspect the source (`wc -c`) and remove unrelated content so only the bundle is piped.","Download the bundle to a file and import by path instead of via stdin.","Split oversized bundles into smaller scoped bundles (global/project separately) under the byte limit."],"exampleFix":"// before\ncurl -s https://example.com/huge-dump.toml | codewhale config import -\n// after\ncurl -sO https://example.com/bundle.toml\ncodewhale config import ./bundle.toml","handlingStrategy":"validation","validationCode":"let mut n = 0usize;\nlet mut buf = [0u8; 65536];\nlet mut stdin = std::io::stdin().lock();\nwhile let Ok(read) = stdin.read(&mut buf) {\n    if read == 0 { break; }\n    n += read;\n    if n as u64 > MAX_BUNDLE_BYTES { eprintln!(\"stdin bundle too large\"); std::process::exit(1); }\n}\n","typeGuard":null,"tryCatchPattern":"match run_import(&args, &store) {\n    Err(e) if e.to_string().contains(\"exceeds the\") && e.to_string().contains(\"byte limit\") => {\n        eprintln!(\"import the bundle from a trimmed file instead of stdin\");\n    }\n    other => other?,\n}","preventionTips":["Pipe only the bundle file: `codewhale config import - < bundle.toml`, not a broader stream.","Check `wc -c` of the source before piping.","Prefer file-path sources for large bundles so size is checked via metadata."],"tags":["cli","config","stdin","size-limit"],"backgroundTag":"file-size-limit-exceeded","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-22T06:17:15.046Z"}