JuliusBrussee/caveman · error
eval evidence line must be a JSON object
Error message
eval evidence line ${index + 1} must be a JSON object What it means
Beyond being parseable JSON, every evidence line must be a JSON object (a record). Lines that parse to strings, numbers, booleans, null, or arrays are rejected with the 1-based line number, since the batch API expects object records.
Solutions
- Rewrite the offending line as a single JSON object record (one object per line).
- If you have an array, split it: `jq -c '.[]' array.json > evidence.jsonl` then re-import.
- Filter out non-object lines: `jq -c 'select(type == "object")' evidence.jsonl > fixed.jsonl`.
Example fix
// before (evidence.jsonl)
[{"case":"t1","score":1.0}]
// error: eval evidence line 1 must be a JSON object
// after
jq -c '.[]' evidence.jsonl > fixed.jsonl
# fixed.jsonl: {"case":"t1","score":1.0} Defensive patterns
Strategy: validation
Validate before calling
// shell jq -c 'select(type != "object")' evidence.jsonl | head # any output = invalid lines # or normalize: jq -c 'select(type == "object")' evidence.jsonl > fixed.jsonl
Prevention
- Ensure one JSON object per line; never dump whole arrays to a single line.
- Filter non-object lines with jq before import.
- Fix the exporter to always emit object records.
When it happens
Trigger: Running `caveman audit eval-import` where a line parses but is not a plain object — e.g. a bare `"ok"` string, a number, a JSON array of records on one line, or a `null` line.
Common situations: Exporting an array to a single line instead of one object per line; logging plain values/strings between records; a generator emitting `null` placeholders for skipped cases.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- eval evidence line is not valid JSON
- eval evidence batch exceeds 1000 records
- eval evidence file contains no records
- eval evidence file exceeds 4 MiB batch limit
- --pubkey JSON must contain public_key or public_keys
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/67efc2220f7b2134.
Report an issue: GitHub.
Appendix: source
Thrown at packages/cli/src/index.ts:17614
// 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",
},
body: JSON.stringify({
...(project ? { project_id: project } : {}),
dry_run: argv.includes("--dry-run"),View on GitHub (pinned to 3ee70a1026)