{"record":{"id":"20c7068c29d8a96d","repo":"JuliusBrussee/caveman","slug":"eval-evidence-file-contains-no-records","errorCode":null,"errorMessage":"eval evidence file contains no records","messagePattern":"eval evidence file contains no records","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cli/src/index.ts","lineNumber":17619,"sourceCode":"  if (data.byteLength > 4 * 1024 * 1024) throw new Error(\"eval evidence file exceeds 4 MiB batch limit\");\n\n  const items: Record<string, unknown>[] = [];\n  for (const [index, rawLine] of data.toString(\"utf8\").split(/\\r?\\n/).entries()) {\n    const line = rawLine.trim();\n    if (!line) continue;\n    let parsed: unknown;\n    try {\n      parsed = JSON.parse(line);\n    } catch {\n      throw new Error(`eval evidence line ${index + 1} is not valid JSON`);\n    }\n    if (!parsed || typeof parsed !== \"object\" || Array.isArray(parsed)) {\n      throw new Error(`eval evidence line ${index + 1} must be a JSON object`);\n    }\n    items.push(parsed as Record<string, unknown>);\n    if (items.length > 1000) throw new Error(\"eval evidence batch exceeds 1000 records\");\n  }\n  if (items.length === 0) throw new Error(\"eval evidence file contains no records\");\n\n  const cfg = await config();\n  const project = flagFrom(argv, \"--project\", cfg.projectId ?? \"\");\n  const response = await fetch(`${cfg.baseURL}/api/v1/eval-evidence/batches`, {\n    method: \"POST\",\n    headers: {\n      authorization: `Bearer ${cfg.token}`,\n      \"content-type\": \"application/json\",\n      \"x-cave-csrf\": \"cli\",\n    },\n    body: JSON.stringify({\n      ...(project ? { project_id: project } : {}),\n      dry_run: argv.includes(\"--dry-run\"),\n      items,\n    }),\n  });\n  const body = await response.json();\n  if (!response.ok) throw new Error(`eval evidence import failed (${response.status}): ${JSON.stringify(body)}`);","sourceCodeStart":17601,"sourceCodeEnd":17637,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/cli/src/index.ts#L17601-L17637","documentation":"After parsing, the CLI requires at least one evidence record before contacting the server. If the file contained only blank lines or whitespace (no non-empty lines survived), it throws this error rather than POSTing an empty batch.","triggerScenarios":"Running `caveman audit eval-import <file>` where the file is empty or contains only whitespace/blank lines, so `items.length === 0` after the parse loop.","commonSituations":"Redirecting output from a command that produced nothing (`> evidence.jsonl` with zero results); a filtered export matching no cases; a CI job exporting before any evals ran.","solutions":["Check the file has content (`wc -l evidence.jsonl`, `cat evidence.jsonl`) and regenerate the export if empty.","Fix the upstream filter/query that produced no matching eval records, then re-export.","Skip the import step in CI when the export is empty instead of invoking the command."],"exampleFix":"// before (shell)\njq -c 'select(.run == \"missing-run\")' all.jsonl > evidence.jsonl\ncaveman audit eval-import evidence.jsonl  # empty file -> contains no records\n// after (shell)\njq -c 'select(.run == \"run-2026-09\")' all.jsonl > evidence.jsonl\n[ -s evidence.jsonl ] && caveman audit eval-import evidence.jsonl","handlingStrategy":"validation","validationCode":"// shell\n[ -s evidence.jsonl ] && grep -qve '^\\s*$' evidence.jsonl || { echo \"evidence file empty; skipping import\"; exit 0; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Guard imports with a non-empty file check (`-s`).","Verify the upstream export actually produced records.","Make CI import steps conditional on file content."],"tags":["cli","audit","eval","empty-input"],"backgroundTag":"empty-required-field","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}