stride3d/stride · error · ArgumentException

index must be Index.Empty.

Error message

index must be Index.Empty.

What it means

MemberNode.UpdateFromMember propagates a changed container value into the member node. A member node represents a single property, so an item index makes no sense — only ItemNodes are indexed. Passing any NodeIndex other than NodeIndex.Empty indicates a caller is treating a member node like an indexed collection node, so ArgumentException is thrown.

Solutions

  1. Pass NodeIndex.Empty when calling UpdateFromMember on a member node.
  2. Branch on the node type: use UpdateFromMember(newIndex) only for item nodes, UpdateFromMember(NodeIndex.Empty) for member nodes.
  3. Use the index-less MemberNode.Update(newValue) API instead when no index is involved.

Example fix

// before
memberNode.UpdateFromMember(newValue, NodeIndex.New(3));
// after
memberNode.UpdateFromMember(newValue, NodeIndex.Empty);
Defensive patterns

Strategy: type-guard

Validate before calling

// C#
if (node is IMemberNode && index != NodeIndex.Empty)
    throw new ArgumentException("Member nodes require NodeIndex.Empty", nameof(index));

Type guard

static bool CanUseIndex(IGraphNode node, NodeIndex index) => node is not IMemberNode || index == NodeIndex.Empty;

Try / catch

try { memberNode.UpdateFromMember(newValue, index); }
catch (ArgumentException ex) when (ex.ParamName == "index") { memberNode.UpdateFromMember(newValue, NodeIndex.Empty); }

Prevention

When it happens

Trigger: Calling ((IMemberNode)node).UpdateFromMember(newValue, someIndex) with an index built via NodeIndex.New(...), or forwarding an index obtained from an item-node change event to a member node's UpdateFromMember.

Common situations: Generic graph-update code that handles both item and member nodes with one path and passes the received index through; refactoring that changed a collection property into a plain property while update code still supplies indices.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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

Appendix: source

Thrown at sources/presentation/Stride.Core.Quantum/MemberNode.cs:97

    protected void NotifyContentChanging(MemberNodeChangeEventArgs args)
    {
        PrepareChange?.Invoke(this, args);
        ValueChanging?.Invoke(this, args);
    }

    /// <summary>
    /// Raises the <see cref="ValueChanged"/> event with the given arguments.
    /// </summary>
    /// <param name="args">The arguments of the event.</param>
    protected void NotifyContentChanged(MemberNodeChangeEventArgs args)
    {
        ValueChanged?.Invoke(this, args);
        FinalizeChange?.Invoke(this, args);
    }

    protected internal override void UpdateFromMember(object newValue, NodeIndex index)
    {
        if (index != NodeIndex.Empty) throw new ArgumentException("index must be Index.Empty.", nameof(index));
        Update(newValue, false);
    }

    private void Update(object? newValue, bool sendNotification)
    {
        var oldValue = Retrieve();
        MemberNodeChangeEventArgs? args = null;
        if (sendNotification)
        {
            args = new MemberNodeChangeEventArgs(this, oldValue, newValue);
            NotifyContentChanging(args);
        }
        var containerValue = Parent.Retrieve() ?? throw new InvalidOperationException("Container's value is null");
        MemberDescriptor.Set(containerValue, ConvertValue(newValue, MemberDescriptor.Type));

        if (containerValue.GetType().GetTypeInfo().IsValueType)
            ((GraphNodeBase)Parent).UpdateFromMember(containerValue, NodeIndex.Empty);

View on GitHub (pinned to 96fad776d2)