remotion-dev/remotion · error · Error
${path}.confidence must be a finite number or null.
Error message
${path}.confidence must be a finite number or null. What it means
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.
Source
Thrown at packages/studio/src/components/parse-caption-file.ts:63
if (!isFiniteNumber(caption.startMs) || caption.startMs < 0) {
throw new Error(`${path}.startMs must be a finite, non-negative number.`);
}
if (!isFiniteNumber(caption.endMs) || caption.endMs < 0) {
throw new Error(`${path}.endMs must be a finite, non-negative number.`);
}
if (caption.endMs < caption.startMs) {
throw new Error(`${path}.endMs must not be earlier than startMs.`);
}
if (caption.timestampMs !== null && !isFiniteNumber(caption.timestampMs)) {
throw new Error(`${path}.timestampMs must be a finite number or null.`);
}
if (caption.confidence !== null && !isFiniteNumber(caption.confidence)) {
throw new Error(`${path}.confidence must be a finite number or null.`);
}
if (
typeof caption.confidence === 'number' &&
(caption.confidence < 0 || caption.confidence > 1)
) {
throw new Error(`${path}.confidence must be between 0 and 1.`);
}
if (
caption.pageBreakAfter !== undefined &&
typeof caption.pageBreakAfter !== 'boolean'
) {
throw new Error(
`${path}.pageBreakAfter must be a boolean when provided.`,
);
}
View on GitHub (pinned to b2f4e34732)
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
Example fix
// before
{"text": "hi", "startMs": 0, "endMs": 1000, "confidence": "high"}
// after
{"text": "hi", "startMs": 0, "endMs": 1000, "confidence": 0.97} Defensive patterns
Strategy: type-guard
Validate before calling
for (const [i, c] of parsed.entries()) {
const conf = (c as any).confidence;
if (conf !== null && conf !== undefined && (typeof conf !== 'number' || !Number.isFinite(conf))) {
throw new Error(`captions[${i}].confidence must be a finite number or null`);
}
} Type guard
const isValidConfidence = (v: unknown): v is number | null | undefined => v === null || v === undefined || (typeof v === 'number' && Number.isFinite(v));
Try / catch
try {
const captions = parseCaptionFile({fileName, contents});
} catch (e) {
// coerce labels like "high"/"95%" to numbers or null, retry
} Prevention
- 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
When it happens
Trigger: captions[i].confidence is "0.95" (string), true, NaN, or Infinity — caught by caption.confidence !== null && !isFiniteNumber(caption.confidence).
Common situations: ASR tools exporting confidence as a percentage string ("95%") or a qualitative label ("high"); NaN from failed parsing before serialization.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- Expected a Remotion Caption[] JSON array.
- ${path} must be an object.
- ${path}.text must be a string.
- ${path}.startMs must be a finite, non-negative number.
- ${path}.endMs must be a finite, non-negative number.
AI-assisted analysis of remotion-dev/remotion@b2f4e34732 (2026-09-09).
Data as JSON: /api/errors/3403a25f1856f2b7.
Report an issue: GitHub.