{"record":{"id":"b2759e5afdc3c62f","repo":"angular/angular-cli","slug":"a-merge-conflicted-on-path-path","errorCode":null,"errorMessage":"A merge conflicted on path \"${path}\".","messagePattern":"A merge conflicted on path \"(.+?)\"\\.","errorType":"exception","errorClass":"MergeConflictException","httpStatus":null,"severity":"error","filePath":"packages/angular_devkit/schematics/src/tree/host-tree.ts","lineNumber":211,"sourceCode":"    const overwriteConflictAllowed =\n      (strategy & MergeStrategy.AllowOverwriteConflict) == MergeStrategy.AllowOverwriteConflict;\n    const deleteConflictAllowed =\n      (strategy & MergeStrategy.AllowDeleteConflict) == MergeStrategy.AllowDeleteConflict;\n\n    other.actions.forEach((action) => {\n      switch (action.kind) {\n        case 'c': {\n          const { path, content } = action;\n\n          if (this._willCreate(path) || this._willOverwrite(path) || this.exists(path)) {\n            const existingContent = this.read(path);\n            if (existingContent && content.equals(existingContent)) {\n              // Identical outcome; no action required\n              return;\n            }\n\n            if (!creationConflictAllowed) {\n              throw new MergeConflictException(path);\n            }\n\n            this._record.overwrite(path, content as {} as virtualFs.FileBuffer).subscribe();\n          } else {\n            this._record.create(path, content as {} as virtualFs.FileBuffer).subscribe();\n          }\n\n          return;\n        }\n\n        case 'o': {\n          const { path, content } = action;\n          if (this._willDelete(path) && !overwriteConflictAllowed) {\n            throw new MergeConflictException(path);\n          }\n\n          // Ignore if content is the same (considered the same change).\n          if (this._willOverwrite(path)) {","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular_devkit/schematics/src/tree/host-tree.ts#L193-L229","documentation":"MergeConflictException from HostTree.merge is thrown when merging a tree whose actions include a Create ('c') for a path that already exists in the target tree, unless creationConflictAllowed was set. Two trees both creating the same file is treated as a conflict because the sink would reject the second create anyway.","triggerScenarios":"tree.merge(other) or branch merging where `other` contains a create action for a path already present in `this`, and options.creationConflictAllowed is not true.","commonSituations":"Composing schematics that each generate the same new file (e.g. both add a README or config); applying a partial schematic to a tree that already staged the same file; re-running generation into a branched tree.","solutions":["Pass { creationConflictAllowed: true } to merge() if overwriting the existing file is intended.","Ensure only one tree creates the file; convert the second side to an overwrite action.","Stagger or namespace generated file paths so the two trees create different files.","Delete the pre-existing file from the target tree before merging."],"exampleFix":"// before\nhost.merge(other); // throws on duplicate creates\n// after\nhost.merge(other, { creationConflictAllowed: true });","handlingStrategy":"try-catch","validationCode":"const conflicts: string[] = [];\nother.actions.forEach((a) => { if (a.kind === 'c' && tree.exists(a.path)) conflicts.push(a.path); });\nif (conflicts.length) { /* resolve or set creationConflictAllowed */ }","typeGuard":"null","tryCatchPattern":"try { host.merge(other); } catch (e) { if (e instanceof MergeConflictException) { host.merge(other, { creationConflictAllowed: true }); } else { throw e; } }","preventionTips":["Namespace generated file paths to avoid cross-schematic collisions","Audit merge() inputs with tree.actions before merging","Decide explicitly on conflict-allowance flags per merge"],"tags":["schematics","merge-conflict","tree"],"backgroundTag":"merge-conflict","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}