{"record":{"id":"19ad4e1fbe64e7d8","repo":"remotion-dev/remotion","slug":"name-must-be-an-object-an-array-was-passed","errorCode":null,"errorMessage":"\"${name}\" must be an object, an array was passed ${compositionId ? `for composition \"${compositionId}\"` : ''}","messagePattern":"\"(.+?)\" must be an object, an array was passed (.+?)\"` : ''\\}","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/validation/validate-default-props.ts","lineNumber":17,"sourceCode":"export const validateDefaultAndInputProps = (\n\tdefaultProps: unknown,\n\tname: 'defaultProps' | 'inputProps',\n\tcompositionId: string | null,\n) => {\n\tif (!defaultProps) {\n\t\treturn;\n\t}\n\n\tif (typeof defaultProps !== 'object') {\n\t\tthrow new Error(\n\t\t\t`\"${name}\" must be an object, but you passed a value of type ${typeof defaultProps}`,\n\t\t);\n\t}\n\n\tif (Array.isArray(defaultProps)) {\n\t\tthrow new Error(\n\t\t\t`\"${name}\" must be an object, an array was passed ${\n\t\t\t\tcompositionId ? `for composition \"${compositionId}\"` : ''\n\t\t\t}`,\n\t\t);\n\t}\n};\n","sourceCodeStart":1,"sourceCodeEnd":24,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/core/src/validation/validate-default-props.ts#L1-L24","documentation":"After confirming `defaultProps`/`inputProps` is an object type, `validateDefaultAndInputProps` additionally rejects arrays. Props must be a keyed object; an array is a common `typeof === 'object'` value that is not a valid props bag. The message includes the composition id when available.","triggerScenarios":"Passing `defaultProps={[...]}` or `inputProps={[...]}` (an Array) to a `<Composition>`. Common when props originate from a JSON file that is a top-level array, or when spreading a list by mistake.","commonSituations":"Loading props from a JSON file whose root is an array; converting a list of items into props and forgetting to wrap under a key; mapping over data and passing the resulting array directly.","solutions":["Wrap the array under a key: `defaultProps={{items: [...]}}`.","If the JSON root is an array, pick a single element or restructure into an object.","Confirm the shape with `Array.isArray()` before assigning."],"exampleFix":"// before\nconst data = require('./props.json'); // data === [{...}, {...}]\n<Composition defaultProps={data} ... />\n// after\nconst data = require('./props.json');\n<Composition defaultProps={{items: data}} ... />","handlingStrategy":"validation","validationCode":"if (Array.isArray(props)) {\n  throw new Error('props must be an object, not an array');\n}","typeGuard":"const isPropsObject = (p) => p == null || (typeof p === 'object' && !Array.isArray(p));","tryCatchPattern":null,"preventionTips":["Never pass a top-level JSON array as props — wrap it under a key.","Validate `!Array.isArray()` on externally-loaded props."],"tags":["validation","composition","default-props","input-props","array"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}