{"record":{"id":"410024d5cdebc783","repo":"diegosouzapw/OmniRoute","slug":"video-frame-is-not-a-jpeg-data-uri","errorCode":null,"errorMessage":"Video frame is not a JPEG data URI","messagePattern":"Video frame is not a JPEG data URI","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/lib/guardrails/videoBridgeHelpers.ts","lineNumber":373,"sourceCode":"\n/**\n * Compare JPEG frames using the versioned 16x16 grayscale visual policy.\n *\n * @param previous - Last frame retained by deduplication.\n * @param current - Candidate frame being evaluated.\n * @param signal - Optional request cancellation signal checked around asynchronous image work.\n * @returns The larger of mean luma delta and the ratio of materially changed cells.\n * @throws When cancelled or when either frame cannot be decoded as a JPEG data URI.\n */\nexport async function compareVideoFramesByGrayscale(\n  previous: VideoCaptionFrame,\n  current: VideoCaptionFrame,\n  signal?: AbortSignal\n): Promise<number> {\n  throwIfVideoDedupAborted(signal);\n  const decode = (dataUri: string): Buffer => {\n    const match = /^data:image\\/jpeg;base64,([A-Za-z0-9+/=]+)$/i.exec(dataUri);\n    if (!match) throw new Error(\"Video frame is not a JPEG data URI\");\n    return Buffer.from(match[1], \"base64\");\n  };\n  const { default: sharp } = await import(\"sharp\");\n  throwIfVideoDedupAborted(signal);\n  const [left, right] = await Promise.all(\n    [previous, current].map((frame) =>\n      sharp(decode(frame.dataUri)).resize(16, 16, { fit: \"fill\" }).greyscale().raw().toBuffer()\n    )\n  );\n  throwIfVideoDedupAborted(signal);\n  if (left.length !== right.length || left.length === 0) {\n    throw new Error(\"Video frame comparison returned invalid dimensions\");\n  }\n  let difference = 0;\n  let changedCells = 0;\n  for (let index = 0; index < left.length; index++) {\n    const cellDifference = Math.abs(left[index] - right[index]) / 255;\n    difference += cellDifference;","sourceCodeStart":355,"sourceCodeEnd":391,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/lib/guardrails/videoBridgeHelpers.ts#L355-L391","documentation":"Error \"Video frame is not a JPEG data URI\" thrown in diegosouzapw/OmniRoute.","triggerScenarios":"Thrown at src/lib/guardrails/videoBridgeHelpers.ts:373 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","schemaVersion":2},"datasetVersion":"2026-08-25T21:54:21.419Z"}