{"record":{"id":"f15cf09dcf4be30e","repo":"Hmbown/CodeWhale","slug":"bundle-at-is-bytes-the-limit-is-max-bundle-bytes-bytes","errorCode":null,"errorMessage":"bundle at {} is {} bytes; the limit is {MAX_BUNDLE_BYTES} bytes","messagePattern":"bundle at (.+?) is (.+?) bytes; the limit is (.+?) bytes","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/cli/src/config_bundles.rs","lineNumber":1501,"sourceCode":"    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\n    let bundle = parse_bundle_bytes(&raw, source_label)?;\n    let prepared = prepare_import(&bundle, store, scope)?;\n    let plan = &prepared.plan;\n\n    println!(\"import plan ({} scope, {source_label}):\", scope.label());\n    println!(\"  added:       {}\", plan.added.len());\n    println!(\"  changed:     {}\", plan.changed.len());\n    println!(\"  skipped:     {}\", plan.skipped.len());\n    println!(\"  conflicting: {}\", plan.conflicting.len());\n    println!(\"  rejected:    {}\", plan.rejected.len());","sourceCodeStart":1483,"sourceCodeEnd":1519,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/crates/cli/src/config_bundles.rs#L1483-L1519","documentation":"The CLI's bundle loader checks the size of a bundle file on disk via std::fs::metadata before reading it, and refuses files larger than MAX_BUNDLE_BYTES. This prevents loading arbitrarily large files into memory and parsing untrusted oversized input. The message includes the actual size and the limit for diagnosis.","triggerScenarios":"Invoking a config-bundle command whose source is a local path where `std::fs::metadata(&path).len() > MAX_BUNDLE_BYTES`; the file is never read, the bail fires immediately after the metadata lookup.","commonSituations":"Pointing the command at the wrong file (a directory dump, a log, a tarball); a bundle that legitimately grew past the limit; stale concatenated exports.","solutions":["Check the file size (`ls -l` / `wc -c`) and confirm it is the intended bundle.","Trim the bundle below MAX_BUNDLE_BYTES (remove redundant entries) and retry.","If the file is not a bundle, pass the correct path.","If bundles legitimately need to be bigger, this is a product limit to raise — but locally, shrink or split the bundle."],"exampleFix":"// before\ncodewhale config bundle import ./accumulated-everything.json\n// after\nls -l accumulated-everything.json   # exceeds limit?\njq '{providers: .providers[0:3]}' accumulated-everything.json > trimmed.json\ncodewhale config bundle import ./trimmed.json","handlingStrategy":"validation","validationCode":"use std::fs;\nlet meta = fs::metadata(path)?;\nif meta.len() > MAX_BUNDLE_BYTES {\n    eprintln!(\"{} is {} bytes; limit is {}\", path.display(), meta.len(), MAX_BUNDLE_BYTES);\n    std::process::exit(1);\n}","typeGuard":"fn is_valid_bundle_file(path: &std::path::Path, max: u64) -> bool {\n    std::fs::metadata(path).map(|m| m.is_file() && m.len() <= max).unwrap_or(false)\n}","tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"the limit is\") => {\n        let size = std::fs::metadata(&path).map(|m| m.len()).unwrap_or(0);\n        eprintln!(\"{path:?} is {size} bytes; trim it below the limit\");\n    }\n    Err(e) => eprintln!(\"import failed: {e:#}\"),\n    Ok(_) => {}\n}","preventionTips":["Stat the file before import; abort early if oversized.","Keep bundles minimal; split large configs into multiple bundles.","Confirm the path points at the actual bundle, not a dump or archive."],"tags":["cli","config","file-size","filesystem"],"backgroundTag":"file-size-limit-exceeded","analyzedSha":"433685b2024e7bc4c99e1e2e326bcad39b4d9d65","analyzedAt":"2026-09-15T12:24:24.634Z","contentChangedAt":"2026-09-15T12:24:24.634Z","schemaVersion":2},"datasetVersion":"2026-09-22T01:17:13.364Z"}