{"record":{"id":"1c5c62b847f94ff3","repo":"remotion-dev/remotion","slug":"argument-passed-to-api-for-param-param-i","errorCode":null,"errorMessage":"Argument passed to \"${api}\" for param \"${param}\" is undefined","messagePattern":"Argument passed to \"(.+?)\" for param \"(.+?)\" is undefined","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/animation-utils/src/transformation-helpers/make-transform/transform-functions.ts","lineNumber":27,"sourceCode":"\tLengthUnit,\n\tLengthUnitString,\n} from '../../type';\nimport {angleUnits, lengthPercentageUnits, lengthUnits} from '../../type';\nimport {isUnitWithString} from './is-unit-with-string';\n\n/* Matrix transformation */\n\nconst checkNumber = ({\n\tnum,\n\tparam,\n\tapi,\n}: {\n\tnum: unknown;\n\tparam: string;\n\tapi: string;\n}) => {\n\tif (typeof num === 'undefined') {\n\t\tthrow new TypeError(\n\t\t\t`Argument passed to \"${api}\" for param \"${param}\" is undefined`,\n\t\t);\n\t}\n\n\tif (typeof num !== 'number') {\n\t\tthrow new TypeError(\n\t\t\t`Argument passed to \"${api}\" for param \"${param}\" is ${JSON.stringify(\n\t\t\t\tnum,\n\t\t\t)}`,\n\t\t);\n\t}\n\n\tif (!Number.isFinite(num)) {\n\t\tthrow new TypeError(\n\t\t\t`Argument passed to \"${api}\" for param \"${param}\" is ${JSON.stringify(\n\t\t\t\tnum,\n\t\t\t)} (must be finite)`,\n\t\t);","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/animation-utils/src/transformation-helpers/make-transform/transform-functions.ts#L9-L45","documentation":"Thrown by the runtime `checkNumber` validator inside the transform helpers (matrix, matrix3d, perspective, rotate, scale, skew, skewX, skewY, translate, translate3d) when a numeric argument is literally `undefined`. The library double-checks at runtime because the public overloads are declared with `...args: unknown[]`, so TypeScript cannot guarantee callers pass real numbers. It fires on the first `undefined` argument it encounters.","triggerScenarios":"Calling any transform helper with an `undefined` value, e.g. `translate(undefined)`, `rotate(missingProp)`, `skew(someObj.notSet)`, or passing fewer positional args than an overload needs after a type assertion (`translate(x as any)` where x is undefined). Also triggered from plain JavaScript (no TS checks) where an unset variable slips through.","commonSituations":"Reading a value from an API response, props object, or interpolated animation array that is optional and was never filled in; destructuring a config object with a missing key; passing the result of `arr[i]` where the index is out of range; migrating from a loose-typed codebase into the typed transform helpers.","solutions":["Inspect the stack trace to find which `api` and `param` are named in the message, then trace that argument back to its source and ensure it is a number before the call.","Default the value at the call site: `translate(x ?? 0)` or guard with `if (typeof x === 'number')`.","Remove any `as any` / `as number` casts on the offending argument so TypeScript catches the undefined path at compile time.","If the value is genuinely optional, branch your animation so the transform helper is only called when the value exists."],"exampleFix":"// before\nconst tx = props.offsetX; // possibly undefined\nconst t = translate(tx);\n\n// after\nconst tx = props.offsetX;\nif (typeof tx !== 'number') {\n  throw new Error('props.offsetX is required');\n}\nconst t = translate(tx);","handlingStrategy":"type-guard","validationCode":"// Before calling any transform helper, confirm the value is a number.\nconst assertTransformNumber = (v: unknown, name: string): number => {\n  if (typeof v !== 'number') {\n    throw new Error(`Transform param ${name} is not a number (got ${v})`);\n  }\n  return v;\n};\n// usage: translate(assertTransformNumber(rawX, 'x'))","typeGuard":"const isTransformNumber = (v: unknown): v is number =>\n  typeof v === 'number' && Number.isFinite(v);\n\n// usage\nif (isTransformNumber(rawX)) {\n  translate(rawX);\n} else {\n  // handle missing value\n}","tryCatchPattern":null,"preventionTips":["Type every value passed to a transform helper as `number` (or the matching unit-string type) so TypeScript rejects undefined at compile time.","Avoid `as any` / `as number` casts on transform arguments.","Validate data from untyped boundaries (APIs, JSON, props) with a typeof guard before animating.","Default optional animation values with `?? 0` only when 0 is a sensible transform value."],"tags":["transform","validation","runtime","typescript"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}