remotion-dev/remotion · error · Error
"${name}" must be an object, an array was passed ${compositi
Error message
"${name}" must be an object, an array was passed ${compositionId ? `for composition "${compositionId}"` : ''} What it means
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.
Source
Thrown at packages/core/src/validation/validate-default-props.ts:17
export const validateDefaultAndInputProps = (
defaultProps: unknown,
name: 'defaultProps' | 'inputProps',
compositionId: string | null,
) => {
if (!defaultProps) {
return;
}
if (typeof defaultProps !== 'object') {
throw new Error(
`"${name}" must be an object, but you passed a value of type ${typeof defaultProps}`,
);
}
if (Array.isArray(defaultProps)) {
throw new Error(
`"${name}" must be an object, an array was passed ${
compositionId ? `for composition "${compositionId}"` : ''
}`,
);
}
};
View on GitHub (pinned to 78fe4bb3fd)
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.
Example fix
// before
const data = require('./props.json'); // data === [{...}, {...}]
<Composition defaultProps={data} ... />
// after
const data = require('./props.json');
<Composition defaultProps={{items: data}} ... /> Defensive patterns
Strategy: validation
Validate before calling
if (Array.isArray(props)) {
throw new Error('props must be an object, not an array');
} Type guard
const isPropsObject = (p) => p == null || (typeof p === 'object' && !Array.isArray(p));
Prevention
- Never pass a top-level JSON array as props — wrap it under a key.
- Validate `!Array.isArray()` on externally-loaded props.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- "${name}" must be an object, but you passed a value of type
- No composition with the ID "${compId}" found.
- No id for composition passed.
- Multiple composition with id ${comp.id} are registered.
- Could not serialize the passed input props to JSON: ${(err a
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/19ad4e1fbe64e7d8.
Report an issue: GitHub.