Hmbown/CodeWhale · error
stdin bundle exceeds the
Error message
stdin bundle exceeds the {MAX_BUNDLE_BYTES} byte limit; refused What it means
This error is thrown by the config-bundle loader in the Codewhale CLI when a bundle is piped in via stdin and its byte count exceeds MAX_BUNDLE_BYTES. The reader deliberately reads MAX_BUNDLE_BYTES+1 bytes so an oversized input is detected, and the command refuses instead of reading an unbounded stream into memory. It is a hard size guard protecting both memory and downstream parsing.
Solutions
- Shrink the bundle so it is under MAX_BUNDLE_BYTES (strip unused providers/sections) and retry.
- Check the bundle's byte size first (`wc -c`) to confirm what is being piped.
- Pass the bundle as a file path argument or via the remote fetch path instead of stdin if that path suits your workflow.
- Verify you are not piping the wrong artifact (a dump/archive) into stdin.
Example fix
// before cat huge-bundle.json | codewhale config bundle import - // after wc -c huge-bundle.json # must be <= MAX_BUNDLE_BYTES jq 'del(.unusedSection)' huge-bundle.json | codewhale config bundle import -
Defensive patterns
Strategy: validation
Validate before calling
const MAX_BUNDLE_BYTES: u64 = /* same constant as the CLI */;
let bytes = read_stdin_to_vec()?;
if bytes.len() as u64 > MAX_BUNDLE_BYTES {
eprintln!("bundle is {} bytes; limit is {}", bytes.len(), MAX_BUNDLE_BYTES);
std::process::exit(1);
} Type guard
fn bundle_within_limit(bytes: &[u8], max: u64) -> bool { (bytes.len() as u64) <= max } Try / catch
match result {
Err(e) if e.to_string().contains("byte limit") => eprintln!("shrink the bundle below the limit before piping"),
Err(e) => eprintln!("import failed: {e:#}"),
Ok(_) => {}
} Prevention
- Check `wc -c` on the bundle before piping it to the CLI.
- Trim unused sections from exported bundles instead of re-exporting everything.
- Prefer passing a file path over stdin so the CLI can pre-check metadata.
- Never pipe dumps, archives, or logs into bundle import commands.
When it happens
Trigger: Running a config-bundle import/install command with the bundle sourced from stdin (source is '-') whose content is larger than MAX_BUNDLE_BYTES; the read already happened before this check, so the bail fires after `reading bundle from stdin` succeeded.
Common situations: Redirecting or piping an exported bundle that grew over time (accumulated providers, big credential blobs); accidentally piping the wrong file (e.g. a full config directory archive or binary) into the command.
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 settings import is not available yet; local config…
- API key input is unexpectedly large
- bundle carries [project] entries; import it with --project…
- cannot resolve the current Codewhale route
AI-assisted analysis of Hmbown/CodeWhale@433685b202 (2026-09-15).
Data as JSON: /api/errors/03506b97b870db3d.
Report an issue: GitHub.
Appendix: source
Thrown at crates/cli/src/config_bundles.rs:1491
};
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 433685b202)