Hmbown/CodeWhale · error
stdin bundle exceeds the
Error message
stdin bundle exceeds the {MAX_BUNDLE_BYTES} byte limit; refused What it means
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.
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.
Example fix
// before curl -s https://example.com/huge-dump.toml | codewhale config import - // after curl -sO https://example.com/bundle.toml codewhale config import ./bundle.toml
Defensive patterns
Strategy: validation
Validate before calling
let mut n = 0usize;
let mut buf = [0u8; 65536];
let mut stdin = std::io::stdin().lock();
while let Ok(read) = stdin.read(&mut buf) {
if read == 0 { break; }
n += read;
if n as u64 > MAX_BUNDLE_BYTES { eprintln!("stdin bundle too large"); std::process::exit(1); }
}
Try / catch
match run_import(&args, &store) {
Err(e) if e.to_string().contains("exceeds the") && e.to_string().contains("byte limit") => {
eprintln!("import the bundle from a trimmed file instead of stdin");
}
other => other?,
} Prevention
- 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.
When it happens
Trigger: Piping a bundle into `config import -` (stdin source) where the stream is larger than MAX_BUNDLE_BYTES bytes.
Common situations: 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.
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
- bundle at is bytes; the limit is bytes
- account_agent_model_unconfigured
- API key input is unexpectedly large
- API key on stdin exceeds the 8 KiB limit
- bundle at is bytes; the limit is bytes
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/03506b97b870db3d.
Report an issue: GitHub.
Appendix: source
Thrown at crates/cli/src/config_bundles.rs:1513
};
validate_scope_target(scope, store.path())?;
let remote_source = args.source.starts_with("https://") || args.source.starts_with("http://");
let source_label = if args.source == "-" {
"stdin"
} else if remote_source {
"remote bundle"
} else {
args.source.as_str()
};
let raw = if args.source == "-" {
let mut buffer = Vec::new();
std::io::stdin()
.lock()
.take(MAX_BUNDLE_BYTES + 1)
.read_to_end(&mut buffer)
.context("reading bundle from stdin")?;
if buffer.len() as u64 > MAX_BUNDLE_BYTES {
bail!("stdin bundle exceeds the {MAX_BUNDLE_BYTES} byte limit; refused");
}
buffer
} else if remote_source {
fetch_bundle(&args.source)?
} else {
let path = PathBuf::from(&args.source);
let metadata = std::fs::metadata(&path)
.with_context(|| format!("reading bundle at {}", path.display()))?;
if metadata.len() > MAX_BUNDLE_BYTES {
bail!(
"bundle at {} is {} bytes; the limit is {MAX_BUNDLE_BYTES} bytes",
path.display(),
metadata.len()
);
}
std::fs::read(&path).with_context(|| format!("reading bundle at {}", path.display()))?
};
View on GitHub (pinned to 73e0f67d83)