stride3d/stride · error · InvalidOperationException

A GraphNode cannot have children when its content hold a ref

Error message

A GraphNode cannot have children when its content hold a reference.

What it means

Thrown by ObjectNode.AddMember when the node's content holds an ItemReferences (a reference to another object). A node that holds a reference to an external object cannot also own child member nodes — the reference and children are mutually exclusive representations of the node content. This fires when initialization tries to add a member to a node whose content was replaced by (or initialized from) a reference, which would produce an inconsistent graph.

Solutions

  1. Do not add member nodes to a node whose content is an ObjectReference; such nodes are opaque reference holders by design.
  2. Resolve the reference first and attach/modify members on the target node (via the reference's TargetNode) instead of on the referencing node.
  3. Restructure the model so reference-holding properties are leaves in the graph, or remove the reference before rebuilding children.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at sources/presentation/Stride.Core.Quantum/ObjectNode.cs:270 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at sources/presentation/Stride.Core.Quantum/ObjectNode.cs:270

            return enumRef.Indices;

        return GetIndices(this);
    }

    public override string ToString()
    {
        return $"{{Node: Object {Type.Name} = [{Value}]}}";
    }

    /// <inheritdoc/>
    void IInitializingObjectNode.AddMember(IMemberNode member, bool allowIfReference)
    {
        if (IsSealed)
            throw new InvalidOperationException("Unable to add a child to a GraphNode that has been sealed");

        // ReSharper disable once HeuristicUnreachableCode - this code is reachable only at the specific moment we call this method!
        if (ItemReferences != null && !allowIfReference)
            throw new InvalidOperationException("A GraphNode cannot have children when its content hold a reference.");

        childrenMap.Add(member.Name, (MemberNode)member);
    }
}

View on GitHub (pinned to 96fad776d2)