{"record":{"id":"915bfbd0b91960d9","repo":"JuliusBrussee/caveman","slug":"eval-evidence-line-index-1-is-not-valid-json","errorCode":null,"errorMessage":"eval evidence line ${index + 1} is not valid JSON","messagePattern":"eval evidence line (.+?) is not valid JSON","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cli/src/index.ts","lineNumber":17611,"sourceCode":"\n// auditEvalImport turns newline-delimited, source-neutral eval records into one\n// bounded batch. Server stamps tenant scope, observed basis, and external-only\n// authority; CI cannot promote its own results into rollout authority.\nasync function auditEvalImport(argv: string[]) {\n  const file = positionalAfterOptions(argv.slice(1), new Set([\"--project\"]));\n  if (!file) throw new Error(`usage: ${invokedCommand(\"audit\")} eval-import <evidence.jsonl> [--project <uuid>] [--dry-run]`);\n  const data = await readFile(file);\n  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    },","sourceCodeStart":17593,"sourceCodeEnd":17629,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/cli/src/index.ts#L17593-L17629","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"// before (evidence.jsonl line 3)\n{\"case\":\"t3\", \"score\":0.9,,}\n// error: eval evidence line 3 is not valid JSON\n// after\n{\"case\":\"t3\", \"score\":0.9}","handlingStrategy":"validation","validationCode":"// shell\nn=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","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["cli","json","audit","eval","parse-error"],"backgroundTag":"json-parse-error","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"}