{"record":{"id":"a50534e04b37728b","repo":"remotion-dev/remotion","slug":"element-source-file-conflicts-with-the-new-composition-file","errorCode":null,"errorMessage":"Element source file conflicts with the new composition file","messagePattern":"Element source file conflicts with the new composition file","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/studio-server/src/preview-server/routes/insert-element.ts","lineNumber":259,"sourceCode":"\t\t\t\t\tsuccess: false,\n\t\t\t\t\ttype: 'file-conflict',\n\t\t\t\t\tconflict: {\n\t\t\t\t\t\tfilePath: plan.filePath,\n\t\t\t\t\t\texistingSource: plan.existingElementSource,\n\t\t\t\t\t\tincomingSource: element.sourceCode,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tcompositionCreation !== null &&\n\t\t\t\tplan.elementFileName ===\n\t\t\t\t\tpath.join(\n\t\t\t\t\t\tpath.dirname(plan.safePaths.compositionFileName),\n\t\t\t\t\t\tpath.basename(compositionCreation.componentFilePath),\n\t\t\t\t\t)\n\t\t\t) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'Element source file conflicts with the new composition file',\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst shouldWriteElementFile =\n\t\t\t\t!plan.elementFileExists || elementSourcesDiffer;\n\t\t\tconst insertionInput = {\n\t\t\t\tremotionRoot,\n\t\t\t\tcompositionFile,\n\t\t\t\tcompositionId,\n\t\t\t\telement: {\n\t\t\t\t\ttype: 'component' as const,\n\t\t\t\t\tcomponentName: plan.componentName,\n\t\t\t\t\timportName: plan.componentName,\n\t\t\t\t\timportPath: plan.importPath,\n\t\t\t\t\tprops: [\n\t\t\t\t\t\t...Object.entries(element.initialProps ?? {}).map(\n\t\t\t\t\t\t\t([name, value]) => ({name, value}),","sourceCodeStart":241,"sourceCodeEnd":277,"githubUrl":"https://github.com/remotion-dev/remotion/blob/46a3a6bf13ca367376ff18bbb06dae2e87e0d068/packages/studio-server/src/preview-server/routes/insert-element.ts#L241-L277","documentation":"The computed install plan includes an elementFileName, and new-composition creation includes a componentFilePath placed next to the composition file. If the element source file path equals the composition's component file path, writing both would clobber the same file, so the route throws before any write occurs.","triggerScenarios":"POSTing to insert-element where plan.elementFileName === path.join(dirname(plan.safePaths.compositionFileName), basename(compositionCreation.componentFilePath)) — the element file name resolves to the same path as the newly generated composition component.","commonSituations":"A crafted or generated request where the element file name was set to the component file's basename, or unusual path configurations making the two computed paths coincide.","solutions":["Choose a distinct element file name so it doesn't equal the composition component file name","Regenerate the install plan after changing installationName","Verify safePaths in the request don't point both files at the same location"],"exampleFix":"// before\nplan.elementFileName = 'MyTitle.tsx'; // same as componentFilePath basename\n// after\nplan.elementFileName = 'MyTitleElement.tsx';","handlingStrategy":"validation","validationCode":"const componentPath = path.join(path.dirname(plan.safePaths.compositionFileName), path.basename(compositionCreation.componentFilePath));\nif (plan.elementFileName === componentPath) throw new Error('element file must differ from composition component file');","typeGuard":null,"tryCatchPattern":"try {\n  await insertElement(payload);\n} catch (e) {\n  if (/conflicts with the new composition file/.test(e.message)) {\n    plan.elementFileName = uniquifyFileName(plan.elementFileName);\n  }\n}","preventionTips":["Keep element file names distinct from generated component names","Regenerate safePaths whenever installationName or target paths change","Sanity-check that all planned output paths are unique before writing"],"tags":["insert-element","file-conflict","filesystem"],"backgroundTag":"source-file-conflict","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"}