{"record":{"id":"3403a25f1856f2b7","repo":"remotion-dev/remotion","slug":"path-confidence-must-be-a-finite-number-or-null","errorCode":null,"errorMessage":"${path}.confidence must be a finite number or null.","messagePattern":"(.+?)\\.confidence must be a finite number or null\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/studio/src/components/parse-caption-file.ts","lineNumber":63,"sourceCode":"\n\t\tif (!isFiniteNumber(caption.startMs) || caption.startMs < 0) {\n\t\t\tthrow new Error(`${path}.startMs must be a finite, non-negative number.`);\n\t\t}\n\n\t\tif (!isFiniteNumber(caption.endMs) || caption.endMs < 0) {\n\t\t\tthrow new Error(`${path}.endMs must be a finite, non-negative number.`);\n\t\t}\n\n\t\tif (caption.endMs < caption.startMs) {\n\t\t\tthrow new Error(`${path}.endMs must not be earlier than startMs.`);\n\t\t}\n\n\t\tif (caption.timestampMs !== null && !isFiniteNumber(caption.timestampMs)) {\n\t\t\tthrow new Error(`${path}.timestampMs must be a finite number or null.`);\n\t\t}\n\n\t\tif (caption.confidence !== null && !isFiniteNumber(caption.confidence)) {\n\t\t\tthrow new Error(`${path}.confidence must be a finite number or null.`);\n\t\t}\n\n\t\tif (\n\t\t\ttypeof caption.confidence === 'number' &&\n\t\t\t(caption.confidence < 0 || caption.confidence > 1)\n\t\t) {\n\t\t\tthrow new Error(`${path}.confidence must be between 0 and 1.`);\n\t\t}\n\n\t\tif (\n\t\t\tcaption.pageBreakAfter !== undefined &&\n\t\t\ttypeof caption.pageBreakAfter !== 'boolean'\n\t\t) {\n\t\t\tthrow new Error(\n\t\t\t\t`${path}.pageBreakAfter must be a boolean when provided.`,\n\t\t\t);\n\t\t}\n","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/remotion-dev/remotion/blob/b2f4e34732f3c6c222ea029413e22dc402218cd7/packages/studio/src/components/parse-caption-file.ts#L45-L81","documentation":"parseCaptionFile allows the optional confidence field to be either null or a finite number; NaN, Infinity, or non-numeric values are rejected. Fires while validating an indexed caption in the loaded captions JSON, before the 0-1 range check.","triggerScenarios":"captions[i].confidence is \"0.95\" (string), true, NaN, or Infinity — caught by caption.confidence !== null && !isFiniteNumber(caption.confidence).","commonSituations":"ASR tools exporting confidence as a percentage string (\"95%\") or a qualitative label (\"high\"); NaN from failed parsing before serialization.","solutions":["Convert confidence to a number, e.g. \"95%\" -> 0.95","Set confidence to null when unknown","Fix NaN-producing code in the export pipeline"],"exampleFix":"// before\n{\"text\": \"hi\", \"startMs\": 0, \"endMs\": 1000, \"confidence\": \"high\"}\n// after\n{\"text\": \"hi\", \"startMs\": 0, \"endMs\": 1000, \"confidence\": 0.97}","handlingStrategy":"type-guard","validationCode":"for (const [i, c] of parsed.entries()) {\n  const conf = (c as any).confidence;\n  if (conf !== null && conf !== undefined && (typeof conf !== 'number' || !Number.isFinite(conf))) {\n    throw new Error(`captions[${i}].confidence must be a finite number or null`);\n  }\n}","typeGuard":"const isValidConfidence = (v: unknown): v is number | null | undefined =>\n  v === null || v === undefined || (typeof v === 'number' && Number.isFinite(v));","tryCatchPattern":"try {\n  const captions = parseCaptionFile({fileName, contents});\n} catch (e) {\n  // coerce labels like \"high\"/\"95%\" to numbers or null, retry\n}","preventionTips":["Normalize ASR confidence labels to numeric probabilities at export","Set confidence to null when the source provides no numeric score","Avoid serializing NaN from failed parseFloat calls"],"tags":["json","validation","captions"],"backgroundTag":"type-mismatch","analyzedSha":"b2f4e34732f3c6c222ea029413e22dc402218cd7","analyzedAt":"2026-09-09T13:27:51.281Z","contentChangedAt":"2026-09-09T13:27:51.281Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}