affaan-m/ECC · error

{label} exceeds the {max_bytes}-byte limit

Error message

{label} exceeds the {max_bytes}-byte limit

What it means

Runtime error from a bounded-file reader in ecc2/src/main.rs. After opening the file and reading up to max_bytes+1 bytes, the code compares content.len() against max_bytes; if the file is larger it bails with "{label} exceeds the {max_bytes}-byte limit". The bound exists to prevent unbounded memory use from oversized inputs.

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 01e15490f0)

Solutions

  1. Confirm you are pointing at the intended file; if it really is that large, trim or split it.
  2. If the input legitimately exceeds the bound, raise max_bytes (if the flag exposes it) or stream the input another way.
  3. Compress or extract only the relevant portion before passing it.
  4. Add a pre-check on file size so the failure surfaces earlier with a clearer message.

Example fix

// before
let content = read_bounded(path, label, 64 * 1024)?; // fails on a 1 MB file

// after
const LIMIT: u64 = 4 * 1024 * 1024;
let size = std::fs::metadata(path)?.len();
if size > LIMIT {
    anyhow::bail!("{label} is {size} bytes; trim it below {LIMIT}");
}
let content = read_bounded(path, label, LIMIT)?;
Defensive patterns

Strategy: validation

Validate before calling

// Preflight the size against the bound before reading.
fn assert_within_limit(label: &str, path: &Path, max_bytes: u64) -> Result<()> {
    let size = std::fs::metadata(path)?.len();
    anyhow::ensure!(size <= max_bytes, "{label} is {size} bytes, exceeds {max_bytes}");
    Ok(())
}

Type guard

fn within_limit(path: &Path, max_bytes: u64) -> bool {
    std::fs::metadata(path).map(|m| m.len() <= max_bytes).unwrap_or(false)
}

Try / catch

let content = read_bounded(label, path, max_bytes).map_err(|e| {
    if e.to_string().contains("exceeds the") {
        anyhow::anyhow!("{e}; trim the file or raise the byte limit")
    } else {
        e
    }
})?;

Prevention

When it happens

Trigger: Passing a file to a bounded-input flag whose size is greater than the flag's max_bytes. The reader deliberately reads one byte past the limit to detect the overflow, then rejects the input.

Common situations: A log or output file grew far beyond expectations; the wrong (huge) file was selected; a generated patch/artifact is unexpectedly large; the default max_bytes is too low for the legitimate use case.

Related errors


AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13). Data as JSON: /api/errors/fdb2d28e4bf7866f. Report an issue: GitHub.