Hmbown/CodeWhale · error

bundle at is bytes; the limit is bytes

Error message

bundle at {source} is {} bytes; the limit is {MAX_BUNDLE_BYTES} bytes

What it means

parse_bundle_bytes enforces a size bound on configuration bundles before any parsing: raw input larger than MAX_BUNDLE_BYTES is refused with the actual and maximum byte counts. Rejecting oversize input before parse keeps memory bounded and catches obviously-wrong inputs early.

Solutions

  1. Check the file size with `wc -c < bundle-file` and confirm it is the intended bundle
  2. Split or prune the bundle contents so it fits under MAX_BUNDLE_BYTES
  3. Re-export a fresh, minimal bundle from the source machine
  4. Ensure you are importing the bundle format (UTF-8 config bundle), not an unrelated file

Example fix

// before
codewhale config-bundles import full-backup.tar.gz   # > MAX_BUNDLE_BYTES
// after
codewhale config-bundles import codewhale-bundle.json
Defensive patterns

Strategy: validation

Validate before calling

// shell guard before import
MAX=1048576  # check MAX_BUNDLE_BYTES for the real limit
[ "$(wc -c < bundle.json)" -le "$MAX" ] || { echo "bundle too large"; exit 1; }

Prevention

When it happens

Trigger: Calling parse_bundle_bytes (public, called by run_import and the oversize-input guard) with raw bytes whose length exceeds MAX_BUNDLE_BYTES — importing a huge file, piping a large stream, or pointing the importer at a binary/log file (crates/cli/src/config_bundles.rs:102).

Common situations: Importing the wrong file (e.g. a database dump or tarball instead of the bundle JSON), an exported bundle that accumulated too much history, or piping unbounded stdin into the import 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


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/ac9dec87eab85adb. Report an issue: GitHub.

Appendix: source

Thrown at crates/cli/src/config_bundles.rs:102

}

/// One bundle section: a flat table of config keys to values. Keys inside a
/// section are data, not schema, so unknown keys parse here — credential
/// rejection happens at plan time by name and value shape.
#[derive(Debug, Clone, Default, Deserialize, Serialize)]
pub struct BundleTable {
    #[serde(flatten)]
    pub entries: std::collections::BTreeMap<String, toml::Value>,
}

// ---------------------------------------------------------------------------
// Parsing (bounded)
// ---------------------------------------------------------------------------

/// Parse a bundle from raw bytes, rejecting oversize input before parse.
pub fn parse_bundle_bytes(raw: &[u8], source: &str) -> Result<PortableBundle> {
    if raw.len() as u64 > MAX_BUNDLE_BYTES {
        bail!(
            "bundle at {source} is {} bytes; the limit is {MAX_BUNDLE_BYTES} bytes",
            raw.len()
        );
    }
    let text = std::str::from_utf8(raw)
        .with_context(|| format!("bundle at {source} is not valid UTF-8"))?;
    parse_bundle_str(text, source)
}

/// Parse a bundle document: TOML by default, JSON when the source ends in
/// `.json` or the document starts with `{`.
pub fn parse_bundle_str(text: &str, source: &str) -> Result<PortableBundle> {
    let trimmed = text.trim_start();
    let bundle = if trimmed.starts_with('{') || source.ends_with(".json") {
        // serde_json keeps the last of two identical object keys. A bundle is
        // a reviewed plan, so a repeated key must fail before anything is
        // planned or written, exactly as TOML already refuses duplicates.
        reject_duplicate_json_keys(text)

View on GitHub (pinned to 73e0f67d83)