{"record":{"id":"23bc88623cd5415c","repo":"stride3d/stride","slug":"the-path-tostring-contains-a-non-valid-item-id-on-an","errorCode":null,"errorMessage":"The path [{ToString()}] contains a non-valid item id on an dictionary.","messagePattern":"The path \\[(.+?)\\] contains a non-valid item id on an dictionary\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/assets/Stride.Core.Assets/Yaml/YamlAssetPath.cs","lineNumber":321,"sourceCode":"                            {\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                            }\n                            else\n                            {\n                                if (key is not int)\n                                {\n                                    throw new InvalidOperationException($\"The path [{ToString()}] contains a non-valid item id on a collection.\");\n                                }\n                            }\n                            memberPath.Push(collectionDescriptor, key);\n                            currentObject = collectionDescriptor.GetValue(currentObject, key);\n                        }\n                        else if (typeDescriptor is DictionaryDescriptor dictionaryDescriptor)\n                        {\n                            if (key is null) throw new InvalidOperationException($\"The path [{ToString()}] contains a non-valid item id on an dictionary.\");\n                            memberPath.Push(dictionaryDescriptor, key);\n                            currentObject = dictionaryDescriptor.GetValue(currentObject, key);\n                        }\n                        break;\n                    }\n                default:\n                    throw new ArgumentOutOfRangeException();\n            }\n        }\n\n        return memberPath;\n    }\n\n    /// <summary>\n    /// Creates a <see cref=\"YamlAssetPath\"/> out of a <see cref=\"MemberPath\"/> instance.\n    /// </summary>\n    /// <param name=\"path\">The <see cref=\"MemberPath\"/> from which to create a <see cref=\"YamlAssetPath\"/>.</param>\n    /// <param name=\"root\">The root object of the given <see cref=\"MemberPath\"/>.</param>","sourceCodeStart":303,"sourceCodeEnd":339,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/assets/Stride.Core.Assets/Yaml/YamlAssetPath.cs#L303-L339","documentation":"Thrown by YamlAssetPath.ToMemberPath when an ItemId path element resolves against a dictionary but the derived key is null. A null key cannot address any dictionary entry, so the library rejects the path rather than producing an invalid MemberPath node.","triggerScenarios":"In the ElementType.ItemId branch, currentObject's descriptor is a DictionaryDescriptor and the key obtained from CollectionItemIdHelper.GetCollectionItemIds(currentObject).GetKey(item.AsItemId()) is null.","commonSituations":"Stored item id no longer present in the dictionary's id map (entry deleted or renamed); asset YAML serialized by an older/other tool version; hand-edited paths pointing at removed dictionary entries.","solutions":["Update the asset YAML to reference an existing dictionary key","Re-add the missing dictionary entry or migrate stored ids after refactoring key types","Regenerate the reference in the editor so the id map and path stay in sync","Catch InvalidOperationException around ToMemberPath and treat it as a stale reference to repair"],"exampleFix":"// before (yaml references an id missing from the dictionary)\nmyDict: !AssetRef itemId=\"missing\"\n// after\nmyDict: !AssetRef key=\"existingKey\"","handlingStrategy":"validation","validationCode":"var key = ids.GetKey(itemId); if (key is null) throw new ArgumentException(\"Dictionary item id does not resolve to a key\");","typeGuard":"bool HasValidDictKey(CollectionItemIds ids, ItemId id) => ids.GetKey(id) != null;","tryCatchPattern":"try { memberPath = yamlPath.ToMemberPath(); } catch (InvalidOperationException) { MarkReferenceBroken(asset, yamlPath); }","preventionTips":["Re-generate references after deleting or renaming dictionary entries","Keep item-id maps in sync when refactoring dictionary key types","Avoid merging asset files whose id maps have diverged","Validate stored item ids against the live object before resolving paths"],"tags":["yaml","asset-path","dictionary","item-id"],"backgroundTag":"entity-not-found","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"}