{"record":{"id":"c92cbb4a8afd5745","repo":"remotion-dev/remotion","slug":"inputrange-must-have-at-least-2-elements","errorCode":null,"errorMessage":"inputRange must have at least 2 elements","messagePattern":"inputRange must have at least 2 elements","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/animation-utils/src/transformation-helpers/interpolate-styles/index.tsx","lineNumber":233,"sourceCode":"\n\t\t// Avoid number to be a string\n\t\tif (!isNaN(Number(finalStyleValue))) {\n\t\t\treturn {\n\t\t\t\t...acc,\n\t\t\t\t[key]: Number(finalStyleValue),\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\t...acc,\n\t\t\t[key]: finalStyleValue,\n\t\t};\n\t}, {});\n};\n\nfunction checkInputRange(arr: readonly number[]) {\n\tif (arr.length < 2) {\n\t\tthrow new Error('inputRange must have at least 2 elements');\n\t}\n\n\tfor (let index = 0; index < arr.length; index++) {\n\t\tif (typeof arr[index] !== 'number') {\n\t\t\tthrow new Error(`inputRange must contain only numbers`);\n\t\t}\n\n\t\tif (arr[index] === -Infinity || arr[index] === Infinity) {\n\t\t\tthrow new Error(\n\t\t\t\t`inputRange must contain only finite numbers, but got [${arr.join(\n\t\t\t\t\t',',\n\t\t\t\t)}]`,\n\t\t\t);\n\t\t}\n\n\t\tif (index > 0 && !(arr[index] > arr[index - 1])) {\n\t\t\tthrow new Error(\n\t\t\t\t`inputRange must be strictly monotonically non-decreasing but got [${arr.join(","sourceCodeStart":215,"sourceCodeEnd":251,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/animation-utils/src/transformation-helpers/interpolate-styles/index.tsx#L215-L251","documentation":"Thrown by checkInputRange when the inputRange array passed to interpolateStyles has fewer than 2 elements. Interpolation requires at least a start and an end point to define a segment, so a 0- or 1-element range cannot be processed.","triggerScenarios":"Calling interpolateStyles(frame, [0], [styleA]) with a single-element range; passing an empty inputRange []; building the range dynamically and ending up with one entry.","commonSituations":"Off-by-one when slicing arrays; a dynamically generated keyframe list that collapsed to one entry; copy-paste from an interpolate() call that was trimmed.","solutions":["Ensure inputRange has at least 2 strictly ascending values, e.g. [0, 30] for a 30-frame transition.","Validate dynamic arrays with inputRange.length >= 2 before calling interpolateStyles.","If you only have one target style, return it directly instead of interpolating."],"exampleFix":"// before\ninterpolateStyles(frame, [0], [{opacity: 1}]);\n\n// after\ninterpolateStyles(frame, [0, 30], [{opacity: 1}, {opacity: 0}]);","handlingStrategy":"validation","validationCode":"if (!Array.isArray(inputRange) || inputRange.length < 2) {\n  throw new Error('inputRange must have at least 2 elements');\n}","typeGuard":"const isValidInputRange = (arr: unknown): arr is number[] =>\n  Array.isArray(arr) && arr.length >= 2 && arr.every((x) => typeof x === 'number' && Number.isFinite(x));","tryCatchPattern":null,"preventionTips":["Hard-code at least two frame endpoints for static animations (e.g. [0, durationInFrames - 1]).","Assert inputRange.length >= 2 for any dynamically built range.","Return a single style directly when only one target is needed."],"tags":["interpolate-styles","input-range","validation"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}