stride3d/stride · error · ArgumentException
The value must be an Index when type is ElementType.Index.
Error message
The value must be an Index when type is ElementType.Index.
What it means
GraphNodePath.PushElement throws ArgumentException when ElementType.Index is requested but the value is not a NodeIndex. Index segments must be Quantum NodeIndex instances so they can represent both list indices and dictionary keys uniformly.
Solutions
- Wrap the index/key in NodeIndex before pushing (NodeIndex.New(value))
- Use the typed PushIndex(NodeIndex) helper
- Convert int indices via NodeIndex.New(i) and dictionary keys likewise
- Catch ArgumentException and validate the element type in generic path builders
Example fix
// before path.Push(3, ElementType.Index); // after path.PushIndex(NodeIndex.New(3));
Defensive patterns
Strategy: type-guard
Validate before calling
if (elementValue is not NodeIndex) throw new ArgumentException("Index path element must be a NodeIndex"); Type guard
bool IsIndexElement(object? v) => v is NodeIndex;
Try / catch
try { path.Push(value, ElementType.Index); } catch (ArgumentException ex) { logger.LogError(ex, "Invalid index path element"); } Prevention
- Always wrap indices/keys in NodeIndex.New(...) before pushing
- Use PushIndex(NodeIndex) instead of the generic overload
- Convert raw ints/keys at the boundary of path-building code
When it happens
Trigger: Calling Push/PushIndex with a raw int, string key, or other type instead of a NodeIndex when pushing an ElementType.Index segment.
Common situations: Passing plain integers from UI code into path builders; forgetting to wrap dictionary keys in NodeIndex.New(key); copying path code that used ints.
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
- Expecting relative path
- filePath must be relative
- Invalid relative path. Expecting an absolute project path
- The value must be a non-null string when type is…
- The value must be null when type is ElementType.Target.
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/25bc919bff4e0c5d.
Report an issue: GitHub.
Appendix: source
Thrown at sources/presentation/Stride.Core.Quantum/GraphNodePath.cs:451
}
private void PushElement(object? elementValue, ElementType type)
{
switch (type)
{
case ElementType.Member:
if (elementValue is not string name)
throw new ArgumentException("The value must be a non-null string when type is ElementType.Member.");
path.Add(NodePathElement.CreateMember(name));
break;
case ElementType.Target:
if (elementValue != null)
throw new ArgumentException("The value must be null when type is ElementType.Target.");
path.Add(NodePathElement.CreateTarget());
break;
case ElementType.Index:
if (!(elementValue is NodeIndex))
throw new ArgumentException("The value must be an Index when type is ElementType.Index.");
path.Add(NodePathElement.CreateIndex((NodeIndex)elementValue));
break;
default:
throw new ArgumentOutOfRangeException(nameof(type));
}
}
}
View on GitHub (pinned to 96fad776d2)