{"record":{"id":"d78290e84c3844c6","repo":"remotion-dev/remotion","slug":"could-not-find-composition-codemod-idtoduplicat","errorCode":null,"errorMessage":"Could not find composition \"${codemod.idToDuplicate}\" to duplicate","messagePattern":"Could not find composition \"(.+?)\" to duplicate","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/browser-studio/src/browser-studio-operations.ts","lineNumber":1772,"sourceCode":"\t\t\t\t\teffectIndex: keyframe.effectIndex,\n\t\t\t\t\tschema: keyframe.schema,\n\t\t\t\t\tupdates: [{key: keyframe.key, operation: keyframe.settings}],\n\t\t\t\t})),\n\t\t\t});\n\t\t\treturn {success: true};\n\t\t},\n\t};\n\n\tconst duplicateComposition: BrowserStudioOperations['duplicateComposition'] =\n\t\tasync ({codemod, dryRun}) => {\n\t\t\ttry {\n\t\t\t\tconst project = getProject();\n\t\t\t\tconst compositionFile = getCompositionFile({\n\t\t\t\t\tcompositionId: codemod.idToDuplicate,\n\t\t\t\t\tproject,\n\t\t\t\t});\n\t\t\t\tif (compositionFile === null) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Could not find composition \"${codemod.idToDuplicate}\" to duplicate`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst absolutePath = findProjectFile({\n\t\t\t\t\tfilePath: compositionFile,\n\t\t\t\t\tproject,\n\t\t\t\t});\n\t\t\t\tconst input = project.files[absolutePath];\n\t\t\t\tconst {newContents} = duplicateCompositionInSource({\n\t\t\t\t\tinput,\n\t\t\t\t\tcodemod,\n\t\t\t\t});\n\t\t\t\tconst {output} = await formatCodemodFile({contents: newContents});\n\t\t\t\tconst diff = simpleDiff({\n\t\t\t\t\toldLines: input.split('\\n'),\n\t\t\t\t\tnewLines: output.split('\\n'),\n\t\t\t\t});","sourceCodeStart":1754,"sourceCodeEnd":1790,"githubUrl":"https://github.com/remotion-dev/remotion/blob/8f9775815716e25b2a9fd9c5511015a17624243d/packages/browser-studio/src/browser-studio-operations.ts#L1754-L1790","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["List current compositions and pass an id that exists right now","If the composition was deleted, refresh the UI instead of duplicating","Check exact spelling and casing of the id","Call `getCompositionFile(compositionId)` first and only duplicate when it returns non-null"],"exampleFix":"// before\nconst res = await operations.duplicateComposition({\n  codemod: {type: 'duplicate-composition', idToDuplicate: 'intro', compositionId: 'intro2'},\n  dryRun: false,\n});\n\n// after\nif (operations.getCompositionFile('intro') === null) {\n  throw new Error('Composition \"intro\" no longer exists');\n}\nconst res = await operations.duplicateComposition({\n  codemod: {type: 'duplicate-composition', idToDuplicate: 'intro', compositionId: 'intro2'},\n  dryRun: false,\n});\nif (!res.success) console.error(res.reason);","handlingStrategy":"validation","validationCode":"if (operations.getCompositionFile(codemod.idToDuplicate) === null) {\n  throw new Error(`Composition \"${codemod.idToDuplicate}\" does not exist anymore`);\n}\nconst res = await operations.duplicateComposition({codemod, dryRun: false});\nif (!res.success) console.error(res.reason);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Drive composition pickers from live composition lists, not cached state","Refresh composition ids on project change events"],"tags":["compositions","not-found","codemod","browser-studio"],"backgroundTag":"composition-not-found","analyzedSha":"8f9775815716e25b2a9fd9c5511015a17624243d","analyzedAt":"2026-08-22T21:45:17.748Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}