stride3d/stride · error · InvalidOperationException
A node of the path is null but is not the last node.
Error message
A node of the path is null but is not the last node.
What it means
GraphNodePath's enumerator (MoveNext) throws InvalidOperationException when a node in the middle of the path resolves to null while more path elements remain. A null intermediate node means the remaining path segments cannot be resolved, so continuing would be meaningless.
Solutions
- Re-resolve/rebuild the node path after model changes instead of reusing the stale one
- Check node existence (e.g. NodeContainer.TryGetNode) before walking the remaining path
- Avoid mutating the graph while enumerating paths; snapshot first
- Catch InvalidOperationException during iteration and treat the path as invalid
Example fix
// before
foreach (var node in stalePath) { ... }
// after
if (NodeContainer.TryGetNode(path, out var node)) { /* use node */ } Defensive patterns
Strategy: validation
Validate before calling
if (!NodeContainer.TryGetNode(path, out var node)) throw new InvalidOperationException("Path no longer resolves; rebuild it"); Try / catch
try { foreach (var n in graphNodePath) { ... } } catch (InvalidOperationException ex) when (ex.Message.Contains("path is null")) { rebuildPath(); } Prevention
- Rebuild node paths after any graph mutation
- Avoid iterating paths while the model is being changed
- Re-resolve paths instead of caching them across frames
When it happens
Trigger: Enumerating a GraphNodePath whose chained nodes (member/index/target lookups) produced null for a non-final node — e.g. a member node was removed from its parent while a path referencing it was still being walked.
Common situations: Holding stale node paths after the model changed (member deleted, list cleared); iterating paths concurrently with graph mutation; resolving paths against partially built containers.
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
- The value must be a non-null string when type is…
- The value must be null when type is ElementType.Target.
- A collection type
- A reference can only be constructed with the method…
- An error occurred while adding an item to the node, see the…
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/9bed7b8df76c4588.
Report an issue: GitHub.
Appendix: source
Thrown at sources/presentation/Stride.Core.Quantum/GraphNodePath.cs:172
{
current = path.RootNode;
}
else
{
var element = path.path[index];
current = element.Type switch
{
ElementType.Member => ((IObjectNode)Current)[element.Name!],
ElementType.Target => ((IMemberNode)Current).Target,
ElementType.Index => ((IObjectNode)Current).ItemReferences?[element.Index].TargetNode,
_ => throw new ArgumentOutOfRangeException(),
};
}
++index;
// If a node that is not the last one is null, we cannot process the path.
if (current is null && index < path.path.Count)
throw new InvalidOperationException("A node of the path is null but is not the last node.");
return true;
}
public void Reset()
{
index = -1;
}
public readonly IGraphNode Current => current!;
readonly object IEnumerator.Current => current!;
}
private const int DefaultCapacity = 16;
private readonly List<NodePathElement> path;
private GraphNodePath(IGraphNode rootNode, int defaultCapacity)View on GitHub (pinned to 96fad776d2)