{"record":{"id":"56a0a17e02660caa","repo":"heygen-com/hyperframes","slug":"source-errormessage-error","errorCode":null,"errorMessage":"${source}: ${errorMessage(error)}","messagePattern":"\\$\\{source\\}: \\$\\{errorMessage\\(error\\)\\}","errorType":"validation","errorClass":"BatchRenderInputError","httpStatus":null,"severity":"error","filePath":"packages/cli/src/commands/batchRender.ts","lineNumber":95,"sourceCode":"  prepared: PreparedBatchRender;\n  concurrency: number;\n  failFast: boolean;\n  quiet: boolean;\n  json: boolean;\n  renderOne: (row: PreparedBatchRow) => Promise<BatchRenderResult>;\n}\n\nconst PLACEHOLDER_RE = /\\{([A-Za-z0-9_.-]+)\\}/g;\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n  return value !== null && typeof value === \"object\" && !Array.isArray(value);\n}\n\nfunction parseJson(raw: string, source: string): unknown {\n  try {\n    return JSON.parse(raw);\n  } catch (error: unknown) {\n    throw new BatchRenderInputError(\"Invalid JSON in --batch\", `${source}: ${errorMessage(error)}`);\n  }\n}\n\nexport function parseBatchRows(raw: string, source: string): Record<string, unknown>[] {\n  const parsed = parseJson(raw, source);\n  const rows = Array.isArray(parsed) ? parsed : isRecord(parsed) ? parsed.rows : undefined;\n\n  if (!Array.isArray(rows)) {\n    throw new BatchRenderInputError(\n      \"Invalid batch payload\",\n      '--batch must be a JSON array of objects, or an object with a \"rows\" array.',\n    );\n  }\n  if (rows.length === 0) {\n    throw new BatchRenderInputError(\"Empty batch\", `${source} contains zero rows.`);\n  }\n\n  return rows.map((row, index) => {","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/heygen-com/hyperframes/blob/c2996c8626135db5253519359d8a063d3bafad8d/packages/cli/src/commands/batchRender.ts#L77-L113","documentation":"BatchRenderInputError with title 'Invalid JSON in --batch', thrown by parseJson when JSON.parse(raw) fails on the --batch payload (inline string or file contents). The message includes the source label and the underlying parse error so the user can locate the bad JSON. It is the batch equivalent of the single-row invalid-vars error.","triggerScenarios":"Passing --batch a malformed JSON string (trailing comma, single quotes, unquoted keys, truncated), or pointing --batch at a file whose contents are not valid JSON. A payload that parses but has the wrong shape hits error 95 instead.","commonSituations":"Shell-quoting loss on a large inline JSON; hand-editing the batch file and leaving a syntax error; UTF-8 BOM or trailing log lines appended to a JSON file; copy-paste that dropped closing brackets.","solutions":["Validate the payload: `echo '<json>' | jq .` or `jq . batch.json`.","If loading from a file, ensure the file contains only JSON (no trailing log lines, no BOM).","Use strict JSON (double quotes, no trailing commas, no comments)."],"exampleFix":"# before: trailing comma, single quotes\nhyperframes render --batch '[{ \"out\": \"a.mp4\" }, ]'\n\n# after: strict JSON\nhyperframes render --batch '[{\"out\":\"a.mp4\"}]'","handlingStrategy":"validation","validationCode":"function assertValidBatchJson(raw: string, source: string) {\n  try { JSON.parse(raw); }\n  catch (e) { throw new Error(`${source} is not valid JSON: ${(e as Error).message}`); }\n}","typeGuard":null,"tryCatchPattern":"try {\n  parseBatchRows(raw, source);\n} catch (err) {\n  if (err instanceof BatchRenderInputError && err.title === 'Invalid JSON in --batch') {\n    // show jq-validated corrected payload\n  }\n}","preventionTips":["Validate with `jq .` before passing --batch.","When loading from a file, ensure it contains only JSON.","Avoid hand-editing large batch files; generate them."],"tags":["cli","validation","json","batch"],"backgroundTag":null,"analyzedSha":"c2996c8626135db5253519359d8a063d3bafad8d","analyzedAt":"2026-08-12T22:18:56.877Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}