stride3d/stride · error · InvalidOperationException

The node does not contain enumerable references.

Error message

The node does not contain enumerable references.

What it means

IndexedTarget dereferences ItemReferences, which is only populated when the node was created with a ReferenceEnumerable (i.e. it represents a node whose collection items hold references). Nodes without enumerable references throw InvalidOperationException because there is nothing to look up. This is a state error: the API was invoked on a node that cannot support it.

Solutions

  1. Check 'node.ItemReferences != null' (or wrap in try/catch for InvalidOperationException) before calling IndexedTarget
  2. Only call IndexedTarget on nodes that were created with a ReferenceEnumerable / reference-aware builder path
  3. Use the regular indexed item access (this[NodeIndex]) for non-reference collection items instead
  4. Restructure so the node whose targets you need is created with item references enabled

Example fix

// before
var target = node.IndexedTarget(index); // InvalidOperationException on plain nodes
// after
if (node.ItemReferences != null)
    var target = node.IndexedTarget(index);
else
    var target = node[index].Target;
Defensive patterns

Strategy: type-guard

Validate before calling

if (node is ObjectNode on && on.ItemReferences == null) throw new InvalidOperationException("Node has no enumerable references");

Type guard

static bool SupportsIndexedTargets(ObjectNode node) => node.ItemReferences != null;

Try / catch

try { target = node.IndexedTarget(index); }
catch (InvalidOperationException ex) when (ex.Message.Contains("enumerable references"))
{ /* fall back to regular indexed item access or skip node */ }

Prevention

When it happens

Trigger: Calling IndexedTarget on an ObjectNode whose ItemReferences is null — i.e. a plain object node or one created with reference = null — regardless of whether the index is valid.

Common situations: Generic node-visiting code that calls IndexedTarget on every node without checking whether it is a reference-holding (item-reference) node; nodes created before references were attached; mixing ordinary collection nodes with reference-observable nodes.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


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

Appendix: source

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

    /// <inheritdoc/>
    public event EventHandler<ItemChangeEventArgs>? ItemChanging;

    /// <inheritdoc/>
    public event EventHandler<ItemChangeEventArgs>? ItemChanged;

    /// <inheritdoc/>
    public IMemberNode? TryGetChild(string name)
    {
        childrenMap.TryGetValue(name, out var child);
        return child;
    }

    /// <inheritdoc/>
    public IObjectNode? IndexedTarget(NodeIndex index)
    {
        if (index == NodeIndex.Empty) throw new ArgumentException("index cannot be Index.Empty when invoking this method.", nameof(index));
        if (ItemReferences == null) throw new InvalidOperationException("The node does not contain enumerable references.");
        return ItemReferences[index].TargetNode;
    }

    /// <inheritdoc/>
    public void Update(object? newValue, NodeIndex index)
    {
        Update(newValue, index, true);
    }

    /// <inheritdoc/>
    public void Add(object newItem)
    {
        if (Descriptor is CollectionDescriptor collectionDescriptor)
        {
            NodeIndex index = NodeIndex.Empty;
            switch (collectionDescriptor.Category)
            {
                case DescriptorCategory.List:

View on GitHub (pinned to 96fad776d2)