JuliusBrussee/caveman · error
eval evidence line is not valid JSON
Error message
eval evidence line ${index + 1} is not valid JSON What it means
Each non-empty line of the eval evidence file must be a JSON value; the CLI parses line-by-line and rethrows any JSON.parse failure with the 1-based line number. This catches malformed JSONL input before it reaches the server.
Solutions
- Validate the file before import: `while IFS= read -r l; do echo "$l" | jq empty || echo BAD; done < evidence.jsonl` and fix the flagged line.
- Open the file at the reported line number and repair or delete the malformed line.
- Regenerate the evidence export from the source system rather than hand-editing JSONL.
Example fix
// before (evidence.jsonl line 3)
{"case":"t3", "score":0.9,,}
// error: eval evidence line 3 is not valid JSON
// after
{"case":"t3", "score":0.9} Defensive patterns
Strategy: validation
Validate before calling
// shell
n=0; while IFS= read -r l; do n=$((n+1)); [ -z "${l// }" ] && continue; echo "$l" | jq -e empty >/dev/null || echo "bad line $n"; done < evidence.jsonl Prevention
- Validate JSONL with jq before every import.
- Generate JSONL programmatically with json.dumps/json -c instead of hand-editing.
- Avoid editors that mangle encoding; keep files UTF-8 without BOM.
When it happens
Trigger: Running `caveman audit eval-import` where line N of the .jsonl file fails JSON.parse (truncated line, unescaped quotes, trailing commas, concatenation artifact, binary/BOM content).
Common situations: Manually editing the .jsonl and breaking syntax; a previous export interrupted mid-write leaving a truncated final line; generating JSONL with unescaped newlines inside string values; CRLF/encoding issues from Windows editors.
Understand the failure class
Background: JSON parse error: "Unexpected token" / "not valid JSON" / "failed to parse" — what JSON parsers are really complaining about — this error's family across 45 libraries.
Related errors
- eval evidence line must be a JSON object
- eval evidence batch exceeds 1000 records
- eval evidence file contains no records
- eval evidence file exceeds 4 MiB batch limit
- --pubkey JSON is malformed
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/915bfbd0b91960d9.
Report an issue: GitHub.
Appendix: source
Thrown at packages/cli/src/index.ts:17611
// 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");
const cfg = await config();
const project = flagFrom(argv, "--project", cfg.projectId ?? "");
const response = await fetch(`${cfg.baseURL}/api/v1/eval-evidence/batches`, {
method: "POST",
headers: {
authorization: `Bearer ${cfg.token}`,
"content-type": "application/json",
"x-cave-csrf": "cli",
},View on GitHub (pinned to 3ee70a1026)