{"record":{"id":"36f2e3de4a3a55b3","repo":"microsoft/monaco-editor","slug":"cannot-merge-fieldname-property-key-alrea","errorCode":null,"errorMessage":"Cannot merge ${fieldName}: property '${key}' already exists in target with value '${target[key]}', would be overridden with '${value}'","messagePattern":"Cannot merge (.+?): property '(.+?)' already exists in target with value '(.+?)', would be overridden with '(.+?)'","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/ci/build-monaco-editor-pkg.ts","lineNumber":105,"sourceCode":"\t\tawait run('npm run build', { cwd: rootPath });\n\t\tawait run('npm test', { cwd: rootPath });\n\t\tawait run('npm run compile', { cwd: resolve(rootPath, 'webpack-plugin') });\n\t\tawait run('npm run package-for-smoketest-webpack', { cwd: rootPath });\n\t\tawait run('npm run package-for-smoketest-esbuild', { cwd: rootPath });\n\t\tawait run('npm run package-for-smoketest-vite', { cwd: rootPath });\n\t\tawait run('npm run smoketest', { cwd: rootPath });\n\t\t// npm package is now ready to be published in ./out/monaco-editor\n\t});\n}\n\nfunction objectMergeThrowIfSet(\n\ttarget: Record<string, any>,\n\tsource: Record<string, any>,\n\tfieldName: string\n): void {\n\tfor (const [key, value] of Object.entries(source)) {\n\t\tif (key in target) {\n\t\t\tthrow new Error(\n\t\t\t\t`Cannot merge ${fieldName}: property '${key}' already exists in target with value '${target[key]}', would be overridden with '${value}'`\n\t\t\t);\n\t\t}\n\t\ttarget[key] = value;\n\t}\n}\n\nprepareMonacoEditorReleaseStableOrNightly();\n","sourceCodeStart":87,"sourceCodeEnd":114,"githubUrl":"https://github.com/microsoft/monaco-editor/blob/ca1b42dc896b99db78e1c743256e8654e12cea2d/scripts/ci/build-monaco-editor-pkg.ts#L87-L114","documentation":"Thrown by objectMergeThrowIfSet while merging monaco-editor-core's dependencies into monaco-editor's package.json during release packaging. The merge copies every dependency key from core into monaco-editor's dependencies, but refuses to overwrite any key that already exists in the target. This is a deliberate fail-fast guard: a collision means both packages pin the same dependency name (possibly to different versions), and silently picking one would hide a version-conflict bug. The error message names the colliding key and both values.","triggerScenarios":"A release build where monaco-editor's package.json declares a dependency (e.g. a transitive lib also pinned by VS Code core) whose name also appears in monaco-editor-core's dependencies. Happens when core picks up a new dependency, or when monaco-editor adds a dependency that core already ships.","commonSituations":"VS Code core added/changed a dependency after a monaco-editor version bump; a manual edit to monaco-editor's package.json dependencies duplicated a core dependency; dependency alignment drift between the two packages during a release.","solutions":["Read the colliding key and the two versions from the error message, then decide which version is correct and remove the duplicate from one package's dependencies so they no longer both declare it.","If the versions should match, align monaco-editor's pin to monaco-editor-core's pin (or vice versa) and drop one of the entries.","Re-run the build after editing — the merge only proceeds once no key collides.","If the collision is intentional and you accept the core version, remove the entry from monaco-editor's package.json dependencies before running the script."],"exampleFix":"// before — monaco-editor package.json dependencies has:\n\"dependencies\": { \"some-lib\": \"^1.0.0\" }\n// and monaco-editor-core also ships \"some-lib\": \"^2.0.0\" -> throws\n// after — drop the duplicate from monaco-editor so core's version wins:\n\"dependencies\": {}","handlingStrategy":"validation","validationCode":"function assertNoDependencyCollision(target: Record<string,string>, source: Record<string,string>) {\n  const collisions = Object.keys(source).filter(k => k in target);\n  if (collisions.length) {\n    for (const k of collisions) {\n      console.error(`Collision on '${k}': monaco-editor=${target[k]} core=${source[k]}`);\n    }\n    process.exit(2);\n  }\n}\n// run this against the two package.json dependency maps before invoking the build","typeGuard":"function dependencyMapsCompatible(target: Record<string, string>, source: Record<string, string>): boolean {\n  return Object.keys(source).every(k => !(k in target) || target[k] === source[k]);\n}","tryCatchPattern":null,"preventionTips":["Keep monaco-editor's package.json dependencies minimal so they rarely overlap with core's.","Add a CI check that diffs the two dependency lists whenever either package.json changes.","When core adds a dependency, audit monaco-editor's package.json in the same PR."],"tags":["ci","build","dependencies","package-json","merge-conflict"],"backgroundTag":null,"analyzedSha":"ca1b42dc896b99db78e1c743256e8654e12cea2d","analyzedAt":"2026-08-13T02:00:51.380Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}