remotion-dev/remotion · error
Cannot interpolate an input which is not a number
Error message
Cannot interpolate an input which is not a number
What it means
Thrown by interpolate() after the undefined check and range validation, when typeof input !== 'number'. Because undefined is already caught earlier, this fires for other non-number inputs: strings, booleans, objects, null, bigint, symbols, and functions. NaN does not hit this (typeof NaN === 'number') but is handled by extrapolation/clamping downstream.
Solutions
- Coerce the input with Number() and confirm the result is a finite number.
- Type the variable as number upstream so the bad value is caught at compile time.
- Guard the call site to skip interpolation for non-number inputs.
Example fix
// before const r = interpolate(frameStr, [0, 1], [0, 100]); // frameStr is a string // after const r = interpolate(Number(frameStr), [0, 1], [0, 100]);
Defensive patterns
Strategy: type-guard
Validate before calling
if (typeof input !== 'number') {
throw new Error('input must be a number');
}
const r = interpolate(input, inputRange, outputRange); Type guard
const isNumber = (v: unknown): v is number => typeof v === 'number';
Prevention
- Coerce string sources with Number() and check for NaN.
- Type the input as number in component props and function signatures.
- Guard the call site to skip interpolation for non-number inputs.
When it happens
Trigger: interpolate('0', [0,1], [0,100]); interpolate(null, [...], [...]); interpolate(true, [...], [...]); passing a frame value read from a string source without coercion.
Common situations: Reading the current value from a DOM input or URL param (string) and passing it uncoerced; passing an object that wraps a number; null from an optional chain.
Related errors
- input can not be undefined
- must contain only numbers
- outputRange must contain only numbers
- outputRange must contain only numbers, numeric tuples, or…
- outputRange tuples must contain only finite numbers, but got
AI-assisted analysis of remotion-dev/remotion@46a3a6bf13 (2026-09-18).
Data as JSON: /api/errors/9da1ecd64c39cf82.
Report an issue: GitHub.
Appendix: source
Thrown at packages/core/src/interpolate.ts:1315
throw new Error(
'inputRange (' +
inputRange.length +
') and outputRange (' +
outputRange.length +
') must have the same length',
);
}
checkInfiniteRange('inputRange', inputRange);
checkValidInputRange(inputRange);
assertValidInterpolateEasingOption(options?.easing, inputRange.length);
assertValidInterpolatePosterizeOption(options?.posterize);
assertValidInterpolateOutputOption(options?.output);
assertValidInterpolateOutputType(options?.outputType);
if (typeof input !== 'number') {
throw new TypeError('Cannot interpolate an input which is not a number');
}
if (!Array.isArray(outputRange)) {
throw new Error('outputRange must contain only numbers');
}
const outputType = options?.outputType;
if (outputType === 'font-weight') {
if (
!outputRange.every(
(output) => typeof output === 'number' || typeof output === 'string',
)
) {
throw new TypeError(
'Font weight outputRange must contain only numbers or strings',
);
}
View on GitHub (pinned to 46a3a6bf13)