stride3d/stride · error · InvalidOperationException

Unable to add a child to a GraphNode that has been sealed

Error message

Unable to add a child to a GraphNode that has been sealed

What it means

Thrown by ObjectNode.AddMember (IInitializingObjectNode.AddMember) when the node IsSealed. During graph construction the node container adds member nodes to a new ObjectNode; once construction finishes the node is sealed and its children become immutable. Adding a member afterwards would break the invariant that the graph structure is fixed after build, so an InvalidOperationException is thrown. This fires from code touching the graph outside the initialization window.

Solutions

  1. Add all members during node construction/build, before the graph is sealed; check IsSealed before calling AddMember.
  2. If members must be added late, rebuild or recreate the node graph instead of mutating a sealed node.
  3. Find the code path that seals the graph too early (e.g. BuildGraph completing) and move late AddMember calls before it.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at sources/presentation/Stride.Core.Quantum/ObjectNode.cs:266 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/06defcefcf95e6f2. Report an issue: GitHub.

Appendix: source

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

    private IEnumerable<NodeIndex>? GetIndices()
    {
        var enumRef = ItemReferences;
        if (enumRef != null)
            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)