JuliusBrussee/caveman · error

eval evidence file exceeds 4 MiB batch limit

Error message

eval evidence file exceeds 4 MiB batch limit

What it means

Eval evidence is imported as one bounded batch, and the CLI enforces a hard 4 MiB ceiling on the evidence file (read fully into memory before upload). Files larger than 4,194,304 bytes are rejected before any parsing or network call.

Solutions

  1. Split the evidence file into chunks under 4 MiB and import each chunk as a separate batch.
  2. Trim or summarize records before import (e.g. drop verbose payloads) to reduce size.
  3. Compress/rotate older evidence into separate imports rather than one giant file.

Example fix

// before (shell)
caveman audit eval-import ./all-evidence.jsonl  # 12 MiB -> exceeds 4 MiB batch limit
// after (shell)
split -b 3m all-evidence.jsonl chunk_
for f in chunk_*; do caveman audit eval-import "$f" --project 1234-abcd; done
Defensive patterns

Strategy: validation

Validate before calling

// shell
if [ "$(stat -c%s evidence.jsonl)" -gt 4194304 ]; then
  echo "file exceeds 4 MiB; split before import"; exit 1
fi

Prevention

When it happens

Trigger: Running `caveman audit eval-import <file>` where the file's byte length exceeds 4 MiB, throwing immediately after `readFile`.

Common situations: Accumulating months of eval records in one .jsonl file; exporting raw full-payload eval traces instead of summarized records; a CI job concatenating many evidence files into one.

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 JuliusBrussee/caveman@3ee70a1026 (2026-09-20). Data as JSON: /api/errors/389dc6cb36a7a2a1. Report an issue: GitHub.

Appendix: source

Thrown at packages/cli/src/index.ts:17601

  };
  const fieldMap = flagFrom(argv, "--field-map", "");
  if (fieldMap) headers["x-cave-field-map"] = fieldMap;
  const response = await fetch(`${cfg.baseURL}/api/v1/imports?format=${encodeURIComponent(format)}`, {
    method: "POST",
    headers,
    body: data
  });
  print(await response.json());
}

// auditEvalImport turns newline-delimited, source-neutral eval records into one
// bounded batch. Server stamps tenant scope, observed basis, and external-only
// authority; CI cannot promote its own results into rollout authority.
async function auditEvalImport(argv: string[]) {
  const file = positionalAfterOptions(argv.slice(1), new Set(["--project"]));
  if (!file) throw new Error(`usage: ${invokedCommand("audit")} eval-import <evidence.jsonl> [--project <uuid>] [--dry-run]`);
  const data = await readFile(file);
  if (data.byteLength > 4 * 1024 * 1024) throw new Error("eval evidence file exceeds 4 MiB batch limit");

  const items: Record<string, unknown>[] = [];
  for (const [index, rawLine] of data.toString("utf8").split(/\r?\n/).entries()) {
    const line = rawLine.trim();
    if (!line) continue;
    let parsed: unknown;
    try {
      parsed = JSON.parse(line);
    } catch {
      throw new Error(`eval evidence line ${index + 1} is not valid JSON`);
    }
    if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
      throw new Error(`eval evidence line ${index + 1} must be a JSON object`);
    }
    items.push(parsed as Record<string, unknown>);
    if (items.length > 1000) throw new Error("eval evidence batch exceeds 1000 records");
  }
  if (items.length === 0) throw new Error("eval evidence file contains no records");

View on GitHub (pinned to 3ee70a1026)