{"record":{"id":"9ec968f654839599","repo":"stride3d/stride","slug":"multiple-identifiable-objects-with-the-same-id-identifiable","errorCode":null,"errorMessage":"Multiple identifiable objects with the same id {identifiable.Id}","messagePattern":"Multiple identifiable objects with the same id (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/assets/Stride.Core.Assets/Serializers/FixupObjectReferences.cs","lineNumber":95,"sourceCode":"        {\n            this.objectReferences = objectReferences;\n            this.throwOnDuplicateIds = throwOnDuplicateIds;\n            this.logger = logger;\n        }\n\n        public override void VisitObject(object obj, ObjectDescriptor descriptor, bool visitMembers)\n        {\n            if (obj is IIdentifiable identifiable)\n            {\n                // Skip reference, we're looking for real objects\n                if (!objectReferences.Any(x => x.Match(CurrentPath)))\n                {\n                    if (ReferenceableObjects.ContainsKey(identifiable.Id))\n                    {\n                        var message = $\"Multiple identifiable objects with the same id {identifiable.Id}\";\n                        logger?.Error(message);\n                        if (throwOnDuplicateIds)\n                            throw new InvalidOperationException(message);\n                    }\n                    ReferenceableObjects[identifiable.Id] = identifiable;\n                }\n            }\n            base.VisitObject(obj, descriptor, visitMembers);\n        }\n    }\n}\n","sourceCodeStart":77,"sourceCodeEnd":104,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/assets/Stride.Core.Assets/Serializers/FixupObjectReferences.cs#L77-L104","documentation":"FixupObjectReferences.VisitObject collects objects identifiable by ItemId (ReferenceableObjects) during YAML deserialization so references can be fixed up afterwards. When two identifiable objects share the same Id the mapping is ambiguous; the library logs an error and, if throwOnDuplicateIds is enabled, throws InvalidOperationException. Duplicates make reference fix-up non-deterministic.","triggerScenarios":"Deserializing a YAML asset (with throwOnDuplicateIds=true) that contains two IIdentifiable objects with the same Id — typically after copying an object inside the YAML file or merging asset files without regenerating ids.","commonSituations":"Copy-pasting an entity/component block within a scene YAML without changing its Id; git merge of two asset files each referencing the same id; third-party tools generating assets with hard-coded ids.","solutions":["Assign a fresh, unique Id (new Guid/ItemId) to one of the duplicated objects in the YAML file.","Resave the asset in the Stride editor, which regenerates conflicting identifiers.","Fix the merge conflict properly — merge duplicates into one entry rather than keeping both blocks.","If duplicates are tolerated in your pipeline, deserialize with throwOnDuplicateIds=false, but expect last-wins reference resolution."],"exampleFix":"// before (YAML): two entities share an Id\n- !Entity\n  Id: 3f1e...:MyEntity\n- !Entity\n  Id: 3f1e...:MyEntity\n\n// after (YAML)\n- !Entity\n  Id: 3f1e...:MyEntity\n- !Entity\n  Id: 7a9c...:MyEntityCopy","handlingStrategy":"validation","validationCode":"var dupes = LoadYamlText(path)\n    .OfType<IIdentifiable>()\n    .GroupBy(o => o.Id)\n    .Where(g => g.Count() > 1);\nforeach (var g in dupes) Console.WriteLine($\"Duplicate id {g.Key}\");","typeGuard":null,"tryCatchPattern":"try { visitor.Visit(root); }\ncatch (InvalidOperationException ex) when (ex.Message.StartsWith(\"Multiple identifiable objects\")) { /* fix YAML ids and retry */ }","preventionTips":["Never duplicate Id fields when copy-pasting YAML blocks","Resolve asset merge conflicts in the editor, not by hand","Keep throwOnDuplicateIds=true in CI to catch bad files early","Regenerate ids on every asset export"],"tags":["duplicate-id","deserialization","yaml","references"],"backgroundTag":"internal-invariant-violation","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}