{"record":{"id":"802f73c7d78da2bf","repo":"diegosouzapw/OmniRoute","slug":"video-frame-comparison-returned-invalid-dimensions","errorCode":null,"errorMessage":"Video frame comparison returned invalid dimensions","messagePattern":"Video frame comparison returned invalid dimensions","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/lib/guardrails/videoBridgeHelpers.ts","lineNumber":385,"sourceCode":"  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;\n    if (cellDifference >= VIDEO_DEDUP_CELL_DELTA_THRESHOLD) changedCells += 1;\n  }\n  return Math.max(difference / left.length, changedCells / left.length);\n}\n\nexport async function deduplicateVideoFrames(\n  frames: readonly VideoCaptionFrame[],\n  options: {\n    compare?: VideoFrameComparator;\n    maxFrames?: number;\n    signal?: AbortSignal;\n    threshold?: number;","sourceCodeStart":367,"sourceCodeEnd":403,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/lib/guardrails/videoBridgeHelpers.ts#L367-L403","documentation":"Thrown by compareVideoFramesByGrayscale when sharp returns unexpected output dimensions for a 16x16 grayscale resize. This indicates a decoder/edge-case failure in sharp (e.g. truncated or pathological JPEG) rather than bad caller input; the numeric visual-delta contract requires both 16x16 luma grids.","triggerScenarios":"Thrown at src/lib/guardrails/videoBridgeHelpers.ts:385 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the installed sharp/libvips version handles the frame's JPEG variant","Pre-normalize frames (re-encode via sharp before dedup) to a canonical format","Treat the comparison as 'different' and keep both frames when dimensions are invalid"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}