affaan-m/ECC · error

exceeds the -byte limit

Error message

{label} exceeds the {max_bytes}-byte limit

What it means

The bounded input reader enforces a maximum byte size on files it reads: it reads at most `max_bytes + 1` bytes via `Take::read_to_end` and bails if the content length exceeds `max_bytes`. This protects the CLI from unbounded memory consumption when a huge file is passed as input.

Solutions

  1. Reduce the input file size (truncate, split, or preprocess) below the limit.
  2. Raise the `max_bytes` limit if the input is legitimately large and memory allows.
  3. Pre-check the file size with metadata before invoking and surface a friendly message.

Example fix

// before
let content = read_bounded_file(path, label, 1_048_576)?;
// after
let max = 10 * 1_048_576; // raise limit to 10 MiB
let content = read_bounded_file(path, label, max)?;
Defensive patterns

Strategy: validation

Validate before calling

let size = std::fs::metadata(path)?.len();
anyhow::ensure!(size <= max_bytes, "{} is {} bytes, exceeds limit of {}", path.display(), size, max_bytes);

Try / catch

match read_bounded_file(path, label, max_bytes) {
    Ok(content) => content,
    Err(e) if e.to_string().contains("-byte limit") => {
        eprintln!("Input too large: compress, split, or raise the limit");
        std::process::exit(2);
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Passing a file larger than the configured `max_bytes` limit to the bounded reader (e.g. a multi-gigabyte log or dataset fed to a flag with a size cap).

Common situations: Pointing the CLI at a large generated artifact, a log that grew beyond the expected size, or a limit configured too low for a legitimate input.

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 affaan-m/ECC@8321021c54 (2026-09-16). Data as JSON: /api/errors/fdb2d28e4bf7866f. Report an issue: GitHub.

Appendix: source

Thrown at ecc2/src/main.rs:1420

    let file = options
        .open(path)
        .with_context(|| format!("Failed to open {}", path.display()))?;
    let metadata = file
        .metadata()
        .with_context(|| format!("Failed to inspect {}", path.display()))?;
    if !metadata.is_file() {
        anyhow::bail!("{label} must be a regular file");
    }

    let read_limit = max_bytes
        .checked_add(1)
        .context("bounded input byte limit is too large")?;
    let mut content = Vec::new();
    file.take(read_limit)
        .read_to_end(&mut content)
        .with_context(|| format!("Failed to read {}", path.display()))?;
    if content.len() as u64 > max_bytes {
        anyhow::bail!("{label} exceeds the {max_bytes}-byte limit");
    }
    Ok(content)
}

#[tokio::main]
async fn main() -> Result<()> {
    tracing_subscriber::fmt()
        .with_env_filter(EnvFilter::from_default_env())
        .init();

    let cli = Cli::parse();

    let cfg = config::Config::load()?;
    let db = session::store::StateStore::open(&cfg.db_path)?;

    match cli.command {
        Some(Commands::HarnessEval { command }) => match command {
            HarnessEvalCommands::Record {

View on GitHub (pinned to 8321021c54)