heygen-com/hyperframes · error · TypeError
Color curve points must be finite
Error message
Color curve points must be finite
What it means
validateCurvePoints() iterates every point and rejects any whose input or output is not finite (NaN, +Infinity, -Infinity) as a TypeError. Non-finite values poison the cubic interpolation math (tangents become NaN, the whole LUT is corrupted), so they must be caught at the boundary. Number.isFinite excludes Infinity unlike plain truthiness.
Source
Thrown at packages/core/src/colorGradingCurves.ts:80
}
const beforeSpan = valueAt(spans, index - 1);
const afterSpan = valueAt(spans, index);
const beforeWeight = 2 * afterSpan + beforeSpan;
const afterWeight = afterSpan + 2 * beforeSpan;
result[index] = (beforeWeight + afterWeight) / (beforeWeight / before + afterWeight / after);
}
return result;
}
function validateCurvePoints(points: readonly HfColorCurvePoint[], size: number): void {
if (points.length < 2) throw new RangeError("A color curve requires at least two points");
if (!Number.isInteger(size) || size < 2) {
throw new RangeError("Curve LUT size must be at least 2");
}
let previousInput = Number.NEGATIVE_INFINITY;
for (const [input, output] of points) {
if (!Number.isFinite(input) || !Number.isFinite(output)) {
throw new TypeError("Color curve points must be finite");
}
if (input <= previousInput) {
throw new RangeError("Color curve inputs must be strictly increasing");
}
previousInput = input;
}
}
function validateOutputRange(
points: readonly HfColorCurvePoint[],
outputMin: number,
outputMax: number,
): void {
if (!Number.isFinite(outputMin) || !Number.isFinite(outputMax) || outputMin >= outputMax) {
throw new RangeError("Curve output bounds must be finite and increasing");
}
if (points.some(([, output]) => output < outputMin || output > outputMax)) {
throw new RangeError(`Curve outputs must be between ${outputMin} and ${outputMax}`);View on GitHub (pinned to c2996c8626)
Solutions
- Clamp/sanitize every point coordinate with Number.isFinite before constructing the points array, replacing non-finite values with a sensible default.
- Validate UI slider ranges and parse inputs defensively.
Example fix
// before const pts = [[0, 0], [0.5, NaN], [1, 1]]; compileHfColorCurve(pts); // throws Color curve points must be finite // after const clean = pts.map(([i, o]) => [i, Number.isFinite(o) ? o : 0.5] as const); compileHfColorCurve(clean);
Defensive patterns
Strategy: validation
Validate before calling
const clean = points.filter(([i, o]) => Number.isFinite(i) && Number.isFinite(o));
if (clean.length !== points.length) throw new Error('curve has non-finite points'); Type guard
function allFinite(points: readonly (readonly [number, number])[]): boolean {
return points.every(([i, o]) => Number.isFinite(i) && Number.isFinite(o));
} Try / catch
try { compileHfColorCurve(pts); }
catch (err) { if (/must be finite/.test(String(err))) { pts = pts.map(([i,o]) => [i, Number.isFinite(o)?o:0.5] as const); } else throw err; } Prevention
- Sanitize all slider/parse output with Number.isFinite before building points.
- Coerce NaN/Infinity to a sensible default rather than passing through.
When it happens
Trigger: A point produced by division by zero or a failed parseFloat (NaN); Infinity coming from an unbounded UI slider; a deserialized value that was 'null' coerced to 0 then divided; floating point overflow.
Common situations: UI input parsed with Number('') yielding 0 then used in 1/x; a JSON value of null coerced to NaN; sliders with no clamp producing Infinity at extremes; bad math in a curve-editing tool.
Related errors
- A color curve requires at least two points
- Curve LUT size must be at least 2
- Color curve inputs must be strictly increasing
- Curve output bounds must be finite and increasing
- Curve outputs must be between ${outputMin} and ${outputMax}
AI-assisted analysis of heygen-com/hyperframes@c2996c8626 (2026-08-12).
Data as JSON: /api/errors/1a3e423104277885.
Report an issue: GitHub.