stride3d/stride · error · InvalidOperationException

Multiple identifiable objects with the same id

Error message

Multiple identifiable objects with the same id {identifiable.Id}

What it means

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.

Solutions

  1. Assign a fresh, unique Id (new Guid/ItemId) to one of the duplicated objects in the YAML file.
  2. Resave the asset in the Stride editor, which regenerates conflicting identifiers.
  3. Fix the merge conflict properly — merge duplicates into one entry rather than keeping both blocks.
  4. If duplicates are tolerated in your pipeline, deserialize with throwOnDuplicateIds=false, but expect last-wins reference resolution.

Example fix

// before (YAML): two entities share an Id
- !Entity
  Id: 3f1e...:MyEntity
- !Entity
  Id: 3f1e...:MyEntity

// after (YAML)
- !Entity
  Id: 3f1e...:MyEntity
- !Entity
  Id: 7a9c...:MyEntityCopy
Defensive patterns

Strategy: validation

Validate before calling

var dupes = LoadYamlText(path)
    .OfType<IIdentifiable>()
    .GroupBy(o => o.Id)
    .Where(g => g.Count() > 1);
foreach (var g in dupes) Console.WriteLine($"Duplicate id {g.Key}");

Try / catch

try { visitor.Visit(root); }
catch (InvalidOperationException ex) when (ex.Message.StartsWith("Multiple identifiable objects")) { /* fix YAML ids and retry */ }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14). Data as JSON: /api/errors/9ec968f654839599. Report an issue: GitHub.

Appendix: source

Thrown at sources/assets/Stride.Core.Assets/Serializers/FixupObjectReferences.cs:95

        {
            this.objectReferences = objectReferences;
            this.throwOnDuplicateIds = throwOnDuplicateIds;
            this.logger = logger;
        }

        public override void VisitObject(object obj, ObjectDescriptor descriptor, bool visitMembers)
        {
            if (obj is IIdentifiable identifiable)
            {
                // Skip reference, we're looking for real objects
                if (!objectReferences.Any(x => x.Match(CurrentPath)))
                {
                    if (ReferenceableObjects.ContainsKey(identifiable.Id))
                    {
                        var message = $"Multiple identifiable objects with the same id {identifiable.Id}";
                        logger?.Error(message);
                        if (throwOnDuplicateIds)
                            throw new InvalidOperationException(message);
                    }
                    ReferenceableObjects[identifiable.Id] = identifiable;
                }
            }
            base.VisitObject(obj, descriptor, visitMembers);
        }
    }
}

View on GitHub (pinned to 96fad776d2)