remotion-dev/remotion · error · Error

Could not serialize the updated defaultProps value

Error message

Could not serialize the updated defaultProps value

What it means

updateDefaultProps throws this when the serialized replacement for the defaultProps object is undefined — i.e. JSON.stringify-style serialization produced no output. This happens when the new defaultProps value cannot be represented as JSON (undefined root, functions, or circular references), so the codemod cannot write it back into the <Composition> source.

Solutions

  1. Ensure the updated defaultProps value is a JSON-serializable plain object (no undefined/functions/circular refs)
  2. Replace undefined values with null or omit those keys
  3. Pass a plain object literal rather than a class instance or function-returning value
  4. Check the props editor output in Studio for non-JSON values before saving

Example fix

// before
const nextProps = {videoSrc: getSrc(), onDone: handleDone}; // function + maybe undefined
updateDefaultProps({input, compositionId, defaultProps: nextProps});
// after
const nextProps = {videoSrc: 'https://example.com/video.mp4'};
updateDefaultProps({input, compositionId, defaultProps: nextProps});
Defensive patterns

Strategy: validation

Validate before calling

const isJsonSerializable = (v: unknown): boolean => {
  try { JSON.stringify(v); return true; } catch { return false; }
};
if (!isJsonSerializable(nextProps) || nextProps === undefined) throw new Error('defaultProps must be a JSON-serializable object');

Type guard

const isPlainProps = (v: unknown): v is Record<string, unknown> =>
  v !== null && typeof v === 'object' && !Array.isArray(v) &&
  Object.values(v).every((x) => x === null || ['string','number','boolean'].includes(typeof x));

Try / catch

try {
  const {output} = updateDefaultProps({input, compositionId, defaultProps});
} catch (e) {
  if (e instanceof Error && e.message.includes('Could not serialize')) {
    const safe = JSON.parse(JSON.stringify(defaultProps, (_k, v) => v === undefined ? null : v));
    return updateDefaultProps({input, compositionId, defaultProps: safe});
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling updateDefaultProps with a defaultProps value containing undefined at the top level, functions, class instances, or circular references that the serializer cannot stringify.

Common situations: Studio prop editing where props contain non-JSON values (e.g. a component reference, a Date-like object, a Map/Set), or generated default props that include undefined keys instead of null.

Understand the failure class

Background: "JSON serialization failed", "not JSON serializable", "Failed to serialize": why JSON marshaling errors happen and how to fix them — this error's family across 46 libraries.

Related errors


AI-assisted analysis of remotion-dev/remotion@46a3a6bf13 (2026-09-18). Data as JSON: /api/errors/a0a77bde42131cbc. Report an issue: GitHub.

Appendix: source

Thrown at packages/studio-codemods/src/update-default-props.ts:150

			replaceStart = recastLocToOffset(input, valueLoc.start);
			replaceEnd = recastLocToOffset(input, valueLoc.end);

			this.traverse(path); // Continue traversing the AST
		},
	});

	if (replaceStart === undefined || replaceEnd === undefined) {
		throw new Error(
			`Could not find defaultProps for composition "${compositionId}"`,
		);
	}

	// linePrefix includes the JSX container opening brace
	const lineStart = input.lastIndexOf('\n', replaceStart) + 1;
	const linePrefix = input.substring(lineStart, replaceStart + 1);
	const previousValue = input.slice(replaceStart + 1, replaceEnd - 1).trim();
	if (stringified === undefined) {
		throw new Error('Could not serialize the updated defaultProps value');
	}

	const formatted = formatSerializedValue({
		input,
		linePrefix,
		previousValue,
		serialized: stringified,
	});

	// Replace the JSX expression container in the original input
	const output =
		input.substring(0, replaceStart) +
		'{' +
		formatted +
		'}' +
		input.substring(replaceEnd);

	return {output};

View on GitHub (pinned to 46a3a6bf13)