stride3d/stride · error · ArgumentException

index cannot be empty.

Error message

index cannot be empty.

What it means

A validation guard in ObjectNode's item removal path: the itemIndex is null or empty when Remove is called. Removing an item from an indexed collection (list or dictionary) node requires a valid NodeIndex identifying which entry to remove; an empty index cannot address any item, so the operation is rejected. This fires when quantum graph code attempts a collection removal without specifying the target index.

Solutions

  1. Supply the real NodeIndex of the item being removed (obtained from IndexOf/ItemReferences or during enumeration), not NodeIndex.Empty.
  2. Only call Remove on collection-backed nodes; for members use the member-node removal APIs instead.
  3. Guard the call site so a failed index lookup does not fall through to Remove with an empty index.
Defensive patterns

Strategy: validation

When it happens

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

Appendix: source

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

        else if (Descriptor is DictionaryDescriptor dictionaryDescriptor)
        {
            var args = new ItemChangeEventArgs(this, itemIndex, ContentChangeType.CollectionAdd, null, newItem);
            NotifyItemChanging(args);
            dictionaryDescriptor.AddToDictionary(value, itemIndex.Value, newItem);
            UpdateReferences();
            NotifyItemChanged(args);
        }
        else
        {
            throw new NotSupportedException("Unable to set the node value, the collection is unsupported");
        }
    }

    /// <inheritdoc/>
    public void Remove(object item, NodeIndex itemIndex)
    {
        if (!itemIndex.TryGetValue(out var itemIndexValue))
            throw new ArgumentException("index cannot be empty.", nameof(itemIndex));

        var args = new ItemChangeEventArgs(this, itemIndex, ContentChangeType.CollectionRemove, item, null);
        NotifyItemChanging(args);
        if (Descriptor is CollectionDescriptor collectionDescriptor)
        {
            if (collectionDescriptor.HasRemoveAt)
            {
                collectionDescriptor.RemoveAt(value, itemIndex.Int);
            }
            else
            {
                collectionDescriptor.Remove(value, item);
            }
        }
        else if (Descriptor is DictionaryDescriptor dictionaryDescriptor)
        {
            dictionaryDescriptor.Remove(value, itemIndexValue);
        }

View on GitHub (pinned to 96fad776d2)