remotion-dev/remotion · error · Error
${path} must be an object.
Error message
${path} must be an object. What it means
Each element of the top-level JSON array must be a Caption object. This error is thrown when an element is a non-object value (string, number, boolean, null, or a nested array). isObject explicitly rejects arrays and null.
Source
Thrown at packages/studio/src/components/parse-caption-file.ts:39
let parsed: unknown;
try {
parsed = JSON.parse(contents);
} catch (error) {
throw new Error(
`Invalid JSON: ${error instanceof Error ? error.message : String(error)}`,
);
}
if (!Array.isArray(parsed)) {
throw new Error('Expected a Remotion Caption[] JSON array.');
}
let previousStart: number | null = null;
for (const [index, caption] of parsed.entries()) {
const path = `captions[${index}]`;
if (!isObject(caption)) {
throw new Error(`${path} must be an object.`);
}
if (typeof caption.text !== 'string') {
throw new Error(`${path}.text must be a string.`);
}
if (!isFiniteNumber(caption.startMs) || caption.startMs < 0) {
throw new Error(`${path}.startMs must be a finite, non-negative number.`);
}
if (!isFiniteNumber(caption.endMs) || caption.endMs < 0) {
throw new Error(`${path}.endMs must be a finite, non-negative number.`);
}
if (caption.endMs < caption.startMs) {
throw new Error(`${path}.endMs must not be earlier than startMs.`);
}
View on GitHub (pinned to b2f4e34732)
Solutions
- Inspect element captions[i] in the JSON and replace it with a full caption object ({text, startMs, endMs, ...})
- Re-export the caption file from the original tool in Remotion Caption JSON format
- Validate each array element is an object before passing the file to the studio
Example fix
// before
["hello world"]
// after
[{"text": "hello world", "startMs": 0, "endMs": 2000, "timestampMs": null, "confidence": null}] Defensive patterns
Strategy: validation
Validate before calling
const arr: unknown[] = JSON.parse(contents);
arr.forEach((el, i) => {
if (typeof el !== 'object' || el === null || Array.isArray(el)) {
throw new Error(`captions[${i}] must be an object`);
}
}); Type guard
const isCaptionObject = (v: unknown): v is Record<string, unknown> => typeof v === 'object' && v !== null && !Array.isArray(v);
Try / catch
try {
const captions = parseCaptionFile({fileName, contents});
} catch (e) {
// message names captions[i]; fix that element and retry
console.error((e as Error).message);
} Prevention
- Validate every array element is an object before import
- Avoid hand-editing caption JSON; re-export from the source tool
- Use an editor with JSON schema validation
When it happens
Trigger: parseCaptionFile receives contents whose parsed array contains an element like "hello", 42, null, true, or [] at captions[i].
Common situations: A malformed export that flattens captions into mixed values; copy/paste corruption inserting a stray value between objects; manually writing ["line one", "line two"] instead of objects.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- Expected a Remotion Caption[] JSON array.
- ${path}.text must be a string.
- ${path}.startMs must be a finite, non-negative number.
- ${path}.endMs must be a finite, non-negative number.
- ${path}.endMs must not be earlier than startMs.
AI-assisted analysis of remotion-dev/remotion@b2f4e34732 (2026-09-09).
Data as JSON: /api/errors/cfe86c32a07e06dd.
Report an issue: GitHub.