{"record":{"id":"3a3101eaf7bd87f8","repo":"stride3d/stride","slug":"the-path-tostring-contains-non-integer-index-on-a-collection","errorCode":null,"errorMessage":"The path [{ToString()}] contains non-integer index on a collection.","messagePattern":"The path \\[(.+?)\\] contains non-integer index on a collection\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/assets/Stride.Core.Assets/Yaml/YamlAssetPath.cs","lineNumber":274,"sourceCode":"                        {\n                            if (collectionDescriptor is SetDescriptor setDescriptor)\n                            {\n                                if (item.Value is null && !collectionDescriptor.ElementType.IsNullable())\n                                {\n                                    throw new InvalidOperationException($\"The path [{ToString()}] contains a null item on a set.\");\n                                }\n                                if (!setDescriptor.Contains(currentObject, item.Value))\n                                {\n                                    throw new InvalidOperationException($\"The path [{ToString()}] item doesn't exsit on a set.\");\n                                }\n                                memberPath.Push(setDescriptor, item.Value);\n                                currentObject = item.Value;\n                            }\n                            else\n                            {\n                                if (item.Value is not int)\n                                {\n                                    throw new InvalidOperationException($\"The path [{ToString()}] contains non-integer index on a collection.\");\n                                }\n                                memberPath.Push(collectionDescriptor, item.Value);\n                                currentObject = collectionDescriptor.GetValue(currentObject, item.Value);\n                            }\n                        }\n                        else if (typeDescriptor is DictionaryDescriptor dictionaryDescriptor)\n                        {\n                            if (item.Value is null) throw new InvalidOperationException($\"The path [{ToString()}] contains a null key on an dictionary.\");\n                            memberPath.Push(dictionaryDescriptor, item.Value);\n                            currentObject = dictionaryDescriptor.GetValue(currentObject, item.Value);\n                        }\n                        break;\n                    }\n                case ElementType.ItemId:\n                    {\n                        var ids = CollectionItemIdHelper.GetCollectionItemIds(currentObject);\n                        var key = ids.GetKey(item.AsItemId());\n                        var typeDescriptor = TypeDescriptorFactory.Default.Find(currentObject.GetType());","sourceCodeStart":256,"sourceCodeEnd":292,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/assets/Stride.Core.Assets/Yaml/YamlAssetPath.cs#L256-L292","documentation":"Thrown by YamlAssetPath.ToMemberPath when a path element addressing a (non-set) collection is not an integer. IList-based collections are indexed positionally, so a string, float, or item-id style value cannot be used as the index and the conversion fails.","triggerScenarios":"ToMemberPath walks into a CollectionDescriptor that is not a SetDescriptor and item.Value is not int (e.g. a string or itemId was emitted for a list index).","commonSituations":"YAML where a list index was serialized as a quoted number or an item-id reference; mixing list and set/identifier addressing styles when editing assets by hand; version skew between writing and reading serializers.","solutions":["Edit the asset YAML to use a plain integer index for the list element","Correct the code generating the path to push an int for collection (list) elements","Regenerate the asset or reference so the path is rebuilt from the actual object graph","Catch InvalidOperationException and report the invalid path entry to the user"],"exampleFix":"// before\npath.Push(collectionDescriptor, \"2\");\n// after\npath.Push(collectionDescriptor, 2);","handlingStrategy":"validation","validationCode":"if (isCollection && pathItem.Value is not int) throw new ArgumentException(\"Collection index must be an int\");","typeGuard":"bool IsValidCollectionIndex(object v) => v is int;","tryCatchPattern":"try { memberPath = yamlPath.ToMemberPath(); } catch (InvalidOperationException ex) { log.Error($\"Bad list index in '{yamlPath}': {ex.Message}\"); }","preventionTips":["Push int (not string/long) indices for list-typed paths","Do not mix item-id addressing with positional list addressing","Re-generate asset paths after changing a property between list and set/dictionary","Validate YAML indices with a lint pass on hand-edited assets"],"tags":["yaml","asset-path","collections","index"],"backgroundTag":"invalid-argument-value","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}