remotion-dev/remotion · error · Error

Could not find composition "${codemod.idToDuplicate}" to dup

Error message

Could not find composition "${codemod.idToDuplicate}" to duplicate

What it means

Returned as `{success: false, reason}` by duplicateComposition in @remotion/browser-studio when `getCompositionFile({compositionId: codemod.idToDuplicate, project})` returns null — no composition with that id is registered in the virtual project, so there is no source file to duplicate. The composition id must match a `<Composition id="...">` currently known to the project.

Source

Thrown at packages/browser-studio/src/browser-studio-operations.ts:1772

					effectIndex: keyframe.effectIndex,
					schema: keyframe.schema,
					updates: [{key: keyframe.key, operation: keyframe.settings}],
				})),
			});
			return {success: true};
		},
	};

	const duplicateComposition: BrowserStudioOperations['duplicateComposition'] =
		async ({codemod, dryRun}) => {
			try {
				const project = getProject();
				const compositionFile = getCompositionFile({
					compositionId: codemod.idToDuplicate,
					project,
				});
				if (compositionFile === null) {
					throw new Error(
						`Could not find composition "${codemod.idToDuplicate}" to duplicate`,
					);
				}

				const absolutePath = findProjectFile({
					filePath: compositionFile,
					project,
				});
				const input = project.files[absolutePath];
				const {newContents} = duplicateCompositionInSource({
					input,
					codemod,
				});
				const {output} = await formatCodemodFile({contents: newContents});
				const diff = simpleDiff({
					oldLines: input.split('\n'),
					newLines: output.split('\n'),
				});

View on GitHub (pinned to 8f97758157)

Solutions

  1. List current compositions and pass an id that exists right now
  2. If the composition was deleted, refresh the UI instead of duplicating
  3. Check exact spelling and casing of the id
  4. Call `getCompositionFile(compositionId)` first and only duplicate when it returns non-null

Example fix

// before
const res = await operations.duplicateComposition({
  codemod: {type: 'duplicate-composition', idToDuplicate: 'intro', compositionId: 'intro2'},
  dryRun: false,
});

// after
if (operations.getCompositionFile('intro') === null) {
  throw new Error('Composition "intro" no longer exists');
}
const res = await operations.duplicateComposition({
  codemod: {type: 'duplicate-composition', idToDuplicate: 'intro', compositionId: 'intro2'},
  dryRun: false,
});
if (!res.success) console.error(res.reason);
Defensive patterns

Strategy: validation

Validate before calling

if (operations.getCompositionFile(codemod.idToDuplicate) === null) {
  throw new Error(`Composition "${codemod.idToDuplicate}" does not exist anymore`);
}
const res = await operations.duplicateComposition({codemod, dryRun: false});
if (!res.success) console.error(res.reason);

Prevention

When it happens

Trigger: Calling `duplicateComposition({codemod: {type: 'duplicate-composition', idToDuplicate: 'my-comp', ...}})` when 'my-comp' is not a registered composition id; the composition was deleted; the id has a typo or wrong casing; the project was reloaded and ids changed.

Common situations: Stale composition list in the UI after the user deleted or renamed a composition; duplicating from a deep link with an outdated id; race between project reload and the duplicate action.

Related errors


AI-assisted analysis of remotion-dev/remotion@8f97758157 (2026-08-22). Data as JSON: /api/errors/d78290e84c3844c6. Report an issue: GitHub.