stride3d/stride · error · ArgumentException
Invalid path [ ] for action [ ]. Expecting last path to be…
Error message
Invalid path [{0}] for action [{1}]. Expecting last path to be a dictionary item What it means
MemberPathAction.DictionaryRemove requires the last path segment to be a DictionaryPathItem identifying the key to remove. Apply() throws ArgumentException when the final segment is a member, collection item, or array item.
Solutions
- Push a dictionary key segment (PushDictionaryItem) as the final path segment before calling DictionaryRemove.
- For lists/arrays, use MemberPathAction.CollectionRemove instead.
- Validate lastItem is DictionaryPathItem before invoking Apply in generic helper code.
Example fix
// before
var path = new MemberPath();
path.Push(type.GetProperty("Settings"));
path.Apply(root, MemberPathAction.DictionaryRemove, null);
// after
var path = new MemberPath();
path.Push(type.GetProperty("Settings"));
path.PushDictionaryItem("someKey");
path.Apply(root, MemberPathAction.DictionaryRemove, null); Defensive patterns
Strategy: validation
Validate before calling
var last = path.Items[^1];
if (action == MemberPathAction.DictionaryRemove && last is not DictionaryPathItem)
throw new InvalidOperationException("DictionaryRemove requires a dictionary-item path segment."); Type guard
static bool CanDictionaryRemove(MemberPath p) => p.Items.Count > 0 && p.Items[^1] is DictionaryPathItem;
Try / catch
try { path.Apply(root, MemberPathAction.DictionaryRemove, null); }
catch (ArgumentException ex) when (ex.Message.Contains("Expecting last path to be a dictionary item")) { /* push a dictionary-key segment */ } Prevention
- Push the key segment (PushDictionaryItem) as the final segment for dictionary removals.
- Keep separate builder helpers for list-shaped vs dictionary-shaped paths.
When it happens
Trigger: Calling Apply(root, MemberPathAction.DictionaryRemove, null) on a path that ends with a MemberPathItem (e.g. just the dictionary property) or a CollectionPathItem/ArrayPathItem.
Common situations: Reusing a list-shaped path and switching the action to DictionaryRemove; forgetting to push the dictionary-key segment (PushDictionaryItem) after pushing the dictionary member.
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
- Invalid path [ ] for action [ ]. Expecting last path to be…
- Invalid path [ ] for action [ ]. Expecting last path to be…
- An error occurred while updating the value of the node, see…
- An unknown EffectParameterClass was found.
- An unknown EffectParameterType was found.
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/5615c9612851a4a3.
Report an issue: GitHub.
Appendix: source
Thrown at sources/core/Stride.Core.Reflection/MemberPath.cs:253
switch (actionType)
{
case MemberPathAction.CollectionAdd:
if (lastItem is not CollectionPathItem)
{
throw new ArgumentException("Invalid path [{0}] for action [{1}]. Expecting last path to be a collection item".ToFormat(this, actionType));
}
break;
case MemberPathAction.CollectionRemove:
if (lastItem is not (CollectionPathItem or ArrayPathItem))
{
throw new ArgumentException("Invalid path [{0}] for action [{1}]. Expecting last path to be a collection/array item".ToFormat(this, actionType));
}
break;
case MemberPathAction.DictionaryRemove:
if (lastItem is not DictionaryPathItem)
{
throw new ArgumentException("Invalid path [{0}] for action [{1}]. Expecting last path to be a dictionary item".ToFormat(this, actionType));
}
break;
}
var stack = stackTLS;
try
{
object? nextObject = rootObject;
if (stack == null)
{
stack = [];
stackTLS = stack;
}
else
{
stack.Clear();
}View on GitHub (pinned to 96fad776d2)