heygen-com/hyperframes · error · RangeError
Hue curve inputs must be unique
Error message
Hue curve inputs must be unique
What it means
After sorting, the loop at line 182-189 rejects two consecutive points with identical hue values. Duplicate hues make the spline's per-segment span zero, which would divide by zero in pointSlopes (span = point[0] - previous[0]).
Source
Thrown at packages/core/src/colorGradingCurves.ts:188
/** Samples a periodic hue curve without duplicating the 0/360-degree texel. */
export function compileHfHueCurve(
points: readonly HfHueCurvePoint[],
outputMin: number,
outputMax: number,
size = HF_COLOR_CURVE_LUT_SIZE,
): Float32Array {
if (points.length < 3) throw new RangeError("A hue curve requires at least three points");
if (points.length > HF_COLOR_CURVE_MAX_POINTS) {
throw new RangeError(`A hue curve supports at most ${HF_COLOR_CURVE_MAX_POINTS} points`);
}
const sorted = [...points].sort((a, b) => a[0] - b[0]);
for (let index = 0; index < sorted.length; index += 1) {
const point = sorted[index];
if (!point || point[0] < 0 || point[0] >= 360) {
throw new RangeError("Hue curve inputs must be from 0 up to 360 degrees");
}
if (index > 0 && point[0] === sorted[index - 1]?.[0]) {
throw new RangeError("Hue curve inputs must be unique");
}
}
const before = sorted.slice(-2).map(([hue, delta]) => [hue - 360, delta] as const);
const after = sorted.slice(0, 2).map(([hue, delta]) => [hue + 360, delta] as const);
const periodic = [...before, ...sorted, ...after];
validateCurvePoints(periodic, size);
return compileCurveSamples(periodic, size, (index) => (index / size) * 360, outputMin, outputMax);
}
View on GitHub (pinned to c2996c8626)
Solutions
- Detect duplicate hues (e.g. via a Set on the first element) and drop or nudge conflicting points before compile.
- When rounding hues, snap to a fixed grid that cannot collide (or merge deltas at ties).
- Run validateHueCurve() upstream — it flags duplicate hue inputs.
Example fix
// before compileHfHueCurve([[0, 0.1], [120, 0.05], [120, -0.05], [240, 0]], -1, 1); // after — merge or nudge duplicates compileHfHueCurve([[0, 0.1], [120, 0.0], [240, 0]], -1, 1);
Defensive patterns
Strategy: validation
Validate before calling
function dedupeHues(points: readonly [number, number][]): [number, number][] {
const seen = new Set<number>();
return points.filter(([hue]) => {
if (seen.has(hue)) return false;
seen.add(hue);
return true;
});
}
compileHfHueCurve(dedupeHues(points), -1, 1); Type guard
function hasUniqueHues(points: readonly [number, number][]): boolean {
const hues = points.map(([h]) => h);
return new Set(hues).size === hues.length;
} Try / catch
try {
compileHfHueCurve(points, -1, 1);
} catch (err) {
if (err instanceof RangeError && err.message === 'Hue curve inputs must be unique') {
// merge or nudge duplicate hues, then retry
} else throw err;
} Prevention
- Track hues in a Set during authoring to reject duplicates at entry.
- Round hues to a fixed grid that cannot collide.
- Run validateHueCurve() upstream — it reports duplicate hue inputs with the path.
When it happens
Trigger: Two points in the input array whose first element compares equal after sort, e.g. [[120, 0.1], [120, -0.1], [240, 0]]. Float-exact equality is required to trip the check.
Common situations: Copy-paste of a control point; rounding hue to integer degrees producing ties; merging two presets that both anchor the same hue.
Related errors
- A hue curve requires at least three points
- A hue curve supports at most ${HF_COLOR_CURVE_MAX_POINTS} po
- Color curves must include input endpoints 0 and 1
- Hue curve inputs must be from 0 up to 360 degrees
- Invalid color grading for cell "${label}"
AI-assisted analysis of heygen-com/hyperframes@c2996c8626 (2026-08-12).
Data as JSON: /api/errors/2bff12e5a9527309.
Report an issue: GitHub.