{"record":{"id":"2e5c87e3b46daae5","repo":"remotion-dev/remotion","slug":"new-composition-component-does-not-match-installation-target","errorCode":null,"errorMessage":"New composition component does not match installation target","messagePattern":"New composition component 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":313,"sourceCode":"\t\t\t\twrapInSequence: componentOwnsSequence\n\t\t\t\t\t? null\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tdimensions: element.dimensions,\n\t\t\t\t\t\t\tdurationInFrames: element.durationInFrames,\n\t\t\t\t\t\t\tfrom,\n\t\t\t\t\t\t\tname: element.displayName,\n\t\t\t\t\t\t\tposition,\n\t\t\t\t\t\t},\n\t\t\t};\n\t\t\tconst inserted = await insertJsxElementIntoComposition({\n\t\t\t\t...insertionInput,\n\t\t\t\tsourceFileOverrides,\n\t\t\t});\n\t\t\tif (\n\t\t\t\tcompositionCreation !== null &&\n\t\t\t\tinserted.fileName !== compositionCreation.componentFilePath\n\t\t\t) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'New composition component does not match installation target',\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst finalPlan = await getElementInstallPlan({\n\t\t\t\tinstallationName,\n\t\t\t\tdestination: installDestination,\n\t\t\t\telement,\n\t\t\t\tentryPoint,\n\t\t\t\tremotionRoot,\n\t\t\t});\n\t\t\tif (\n\t\t\t\tfinalPlan.safePaths.compositionFileName !==\n\t\t\t\tplan.safePaths.compositionFileName\n\t\t\t) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'Composition source changed during Element installation',\n\t\t\t\t);","sourceCodeStart":295,"sourceCodeEnd":331,"githubUrl":"https://github.com/remotion-dev/remotion/blob/46a3a6bf13ca367376ff18bbb06dae2e87e0d068/packages/studio-server/src/preview-server/routes/insert-element.ts#L295-L331","documentation":"After performing the insertion, the route checks that for a new-composition installation, the file where the element was actually inserted (inserted.fileName) equals compositionCreation.componentFilePath — the file the codemod planned to write the component into. A mismatch means the element landed in a different file than the new component, so the installation is inconsistent and the route aborts.","triggerScenarios":"POSTing to insert-element where resolveInsertion (given insertionType, safePaths, sourceFileOverrides) inserted the element into a file different from the new composition's componentFilePath.","commonSituations":"sourceFileOverrides redirecting the insertion to another file, safePaths computed differently between the plan and resolution steps, or stale request fields after a partial retry.","solutions":["Regenerate the request so sourceFileOverrides and safePaths come from a single fresh plan","Ensure sourceFileOverrides do not redirect insertion away from the new component file","Retry with a clean payload built from the current project state (restart Studio if needed)"],"exampleFix":"// before\nsourceFileOverrides = new Map([['src/Other.tsx', otherSrc]]); // redirects insertion\n// after\nsourceFileOverrides = null; // insert into compositionCreation.componentFilePath","handlingStrategy":"validation","validationCode":"// ensure no override redirects insertion away from the component file\nif (compositionCreation && [...(sourceFileOverrides?.keys() ?? [])].some((f) => path.resolve(f) !== path.resolve(compositionCreation.componentFilePath))) {\n  sourceFileOverrides = null;\n}","typeGuard":null,"tryCatchPattern":"try {\n  await insertElement(payload);\n} catch (e) {\n  if (/component does not match installation target/.test(e.message)) {\n    payload = regenerateInsertPayload(installationName); // rebuild with consistent safePaths/overrides\n  }\n}","preventionTips":["Build the whole request from one plan generation pass","Avoid sourceFileOverrides that move insertion to a different file than the new component","Retry with a freshly generated payload instead of editing a failed one"],"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"}