stride3d/stride · error · InvalidOperationException
The path [ ] contains non-integer index on an array.
Error message
The path [{ToString()}] contains non-integer index on an array. What it means
Thrown by YamlAssetPath.ToMemberPath when converting a serialized asset path into a MemberPath and a path element targeting an array property is not an integer. Array elements can only be addressed by integer index in Stride's property system, so the library rejects any other value type to prevent a bad cast or wrong element access later.
Solutions
- Open the asset .yaml file and change the array index to a bare integer (0, not '0'), or regenerate the asset path from code
- Fix the code that constructs the YamlAssetPath to push an int value for array elements (e.g. (int)someLong)
- Upgrade/align Stride.Core.Assets versions between the tool that wrote the YAML and the one reading it
- Wrap ToMemberPath in a try/catch for InvalidOperationException and surface the offending path to the user
Example fix
// before
path.Items.Add(new YamlAssetPath.InterfaceReference()); // or non-int index
path.Items.Add(new YamlAssetPath.Index("0"));
// after
path.Items.Add(new YamlAssetPath.Index(0)); // int for arrays/collections Defensive patterns
Strategy: validation
Validate before calling
if (pathItem.Value is not int) throw new ArgumentException($"Array index must be an int, got {pathItem.Value?.GetType().Name}"); Type guard
bool IsValidArrayIndex(object v) => v is int;
Try / catch
try { memberPath = yamlPath.ToMemberPath(); } catch (InvalidOperationException ex) { log.Error($"Bad asset path '{yamlPath}': {ex.Message}"); } Prevention
- Always push int values for array/collection indices when building YamlAssetPath in code
- Never quote numbers in hand-edited asset YAML index positions
- Keep writer and reader Stride.Core.Assets versions aligned
- Log the full path string when ToMemberPath fails to speed diagnosis
When it happens
Trigger: Calling ToMemberPath on a YamlAssetPath whose current element is an ItemId/Index whose value is a string, float, or other non-int type while the current object's type descriptor is an ArrayDescriptor.
Common situations: Hand-edited or round-tripped YAML asset files where an array index was written as a quoted string (e.g. '0' instead of 0) or as a float; a serializer upgrade changing the emitted index type; code building YamlAssetPath programmatically with a long or string index.
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
- The path [ ] contains a non-valid item id on an array.
- Unable to extract url reference from object
- The given container does not match the expected type.
- The given container does not match the expected type.
- This item is not a Member
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/8f583d21a37b3863.
Report an issue: GitHub.
Appendix: source
Thrown at sources/assets/Stride.Core.Assets/Yaml/YamlAssetPath.cs:249
{
case ElementType.Member:
{
var typeDescriptor = TypeDescriptorFactory.Default.Find(currentObject.GetType());
var name = item.AsMember();
var memberDescriptor = typeDescriptor.Members.FirstOrDefault(x => x.Name == name)
?? throw new InvalidOperationException($"The path [{ToString()}] contains access to non-existing member [{name}].");
memberPath.Push(memberDescriptor);
currentObject = memberDescriptor.Get(currentObject);
break;
}
case ElementType.Index:
{
var typeDescriptor = TypeDescriptorFactory.Default.Find(currentObject.GetType());
if (typeDescriptor is ArrayDescriptor arrayDescriptor)
{
if (item.Value is not int)
{
throw new InvalidOperationException($"The path [{ToString()}] contains non-integer index on an array.");
}
int value = (int)item.Value;
memberPath.Push(arrayDescriptor, value);
currentObject = arrayDescriptor.GetValue(currentObject, value);
}
else if (typeDescriptor is CollectionDescriptor collectionDescriptor)
{
if (collectionDescriptor is SetDescriptor setDescriptor)
{
if (item.Value is null && !collectionDescriptor.ElementType.IsNullable())
{
throw new InvalidOperationException($"The path [{ToString()}] contains a null item on a set.");
}
if (!setDescriptor.Contains(currentObject, item.Value))
{
throw new InvalidOperationException($"The path [{ToString()}] item doesn't exsit on a set.");
}
memberPath.Push(setDescriptor, item.Value);View on GitHub (pinned to 96fad776d2)