{"record":{"id":"3e468e5037f42dff","repo":"remotion-dev/remotion","slug":"new-composition-source-does-not-match-installation-target-3e468e","errorCode":null,"errorMessage":"New composition source does not match installation target","messagePattern":"New composition source does not match installation target","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/studio-server/src/preview-server/routes/insert-element.ts","lineNumber":152,"sourceCode":"\t\t\t\t\t\t'New composition ID does not match installation target',\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst registrationFilePath = newComposition.symbolicatedStack\n\t\t\t\t\t? resolveFilePathFromSymbolicatedStack(\n\t\t\t\t\t\t\tremotionRoot,\n\t\t\t\t\t\t\tnewComposition.symbolicatedStack,\n\t\t\t\t\t\t)\n\t\t\t\t\t: (await getProjectInfo(remotionRoot, entryPoint)).rootFile;\n\t\t\t\tif (registrationFilePath === null) {\n\t\t\t\t\tthrow new Error('Cannot find file for composition in project');\n\t\t\t\t}\n\n\t\t\t\tcheckIfTypeScriptFile(registrationFilePath);\n\t\t\t\tif (\n\t\t\t\t\tpath.resolve(remotionRoot, compositionFile) !== registrationFilePath\n\t\t\t\t) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t'New composition source does not match installation target',\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst componentFilePath = path.join(\n\t\t\t\t\tpath.dirname(registrationFilePath),\n\t\t\t\t\t`${newComposition.codemod.componentName}.tsx`,\n\t\t\t\t);\n\t\t\t\tif (existsSync(componentFilePath)) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Cannot create ${path.relative(\n\t\t\t\t\t\t\tremotionRoot,\n\t\t\t\t\t\t\tcomponentFilePath,\n\t\t\t\t\t\t)} because it already exists`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst registrationFileOldContents = readFileSync(","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/remotion-dev/remotion/blob/46a3a6bf13ca367376ff18bbb06dae2e87e0d068/packages/studio-server/src/preview-server/routes/insert-element.ts#L134-L170","documentation":"After resolving the registration file for the new composition, the route compares it (resolved to an absolute path) with the compositionFile targeted by the request. If they differ, the new composition would be written to a file other than the requested installation target, so the route refuses to proceed.","triggerScenarios":"POSTing to insert-element with newComposition whose resolved registration file is not the same file as the request's compositionFile — e.g. the codemod resolves to a different Root file than the one the request targeted.","commonSituations":"Multiple Root files in a project, stale symbolicated stack pointing at an old registration file, or compositionFile given as a path that resolves differently (relative vs absolute, symlinked directories).","solutions":["Pass compositionFile as the exact file where the new composition will be registered","Regenerate the plan so symbolicatedStack and compositionFile agree","Remove duplicate Root registrations so resolution is unambiguous"],"exampleFix":"// before\ncompositionFile = 'src/OtherRoot.tsx'; // codemod registers in src/Root.tsx\n// after\ncompositionFile = 'src/Root.tsx';","handlingStrategy":"validation","validationCode":"const resolved = path.resolve(remotionRoot, compositionFile);\nif (registrationFilePath && resolved !== registrationFilePath) {\n  throw new Error('compositionFile must be the file registering the new composition');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await insertElement(payload);\n} catch (e) {\n  if (/source does not match installation target/.test(e.message)) {\n    payload.compositionFile = registrationFilePath; // use the resolved file\n  }\n}","preventionTips":["Pass compositionFile as the same file the codemod/symbolicated stack resolves to","Avoid multiple Root registration files for one project","Use absolute, symlink-free paths in requests"],"tags":["insert-element","path-mismatch","validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"46a3a6bf13ca367376ff18bbb06dae2e87e0d068","analyzedAt":"2026-09-18T00:12:20.256Z","contentChangedAt":"2026-09-18T00:12:20.256Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}