{"record":{"id":"092b10fd7bc42104","repo":"stride3d/stride","slug":"this-item-is-not-a-item-id","errorCode":null,"errorMessage":"This item is not a item Id","messagePattern":"This item is not a item Id","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/assets/Stride.Core.Assets/Yaml/YamlAssetPath.cs","lineNumber":78,"sourceCode":"        }\n\n        /// <summary>\n        /// Fetches the name of the member, considering this element is a <see cref=\"ElementType.Member\"/>.\n        /// </summary>\n        /// <returns>The name of the member.</returns>\n        public readonly string AsMember()\n        {\n            if (Type != ElementType.Member) throw new InvalidOperationException(\"This item is not a Member\");\n            return (string)Value;\n        }\n\n        /// <summary>\n        /// Returns the <see cref=\"ItemId\"/> of this element, considering this element is a <see cref=\"ElementType.ItemId\"/>.\n        /// </summary>\n        /// <returns>The <see cref=\"ItemId\"/> of the item.</returns>\n        public readonly ItemId AsItemId()\n        {\n            if (Type != ElementType.ItemId) throw new InvalidOperationException(\"This item is not a item Id\");\n            return (ItemId)Value;\n        }\n\n        /// <inheritdoc/>\n        public readonly bool Equals(Element other)\n        {\n            return Type == other.Type && Equals(Value, other.Value);\n        }\n\n        /// <inheritdoc/>\n        public override readonly bool Equals(object? obj)\n        {\n            if (ReferenceEquals(null, obj)) return false;\n            return obj is Element element && Equals(element);\n        }\n\n        /// <inheritdoc/>\n        public override readonly int GetHashCode()","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/assets/Stride.Core.Assets/Yaml/YamlAssetPath.cs#L60-L96","documentation":"YamlAssetPath.Element.AsItemId() casts the element's Value to ItemId and throws InvalidOperationException('This item is not a item Id') when the element's Type is not ElementType.ItemId (e.g. it is a Member or Index).","triggerScenarios":"Calling AsItemId() on a Member or Index element — e.g. extracting object ids from remapping paths where only some elements carry item ids.","commonSituations":"Asset-upgrade/dependency-fixup code scanning paths for ItemIds; scripts that assume every path element has an id; paths built for plain members (no collection) then processed with item-id logic.","solutions":["Check element.Type == ElementType.ItemId before calling AsItemId()","Dispatch on ElementType instead of assuming the kind","Fix the path construction site to push ItemId elements where expected","Skip non-ItemId elements in loops that collect ids"],"exampleFix":"// before\nvar id = element.AsItemId();\n// after\nvar id = element.Type == YamlAssetPath.ElementType.ItemId ? element.AsItemId() : (ItemId?)null;","handlingStrategy":"type-guard","validationCode":"if (element.Type != YamlAssetPath.ElementType.ItemId) return; // not an id element","typeGuard":"bool TryAsItemId(in YamlAssetPath.Element e, out ItemId id)\n{ id = e.Type == YamlAssetPath.ElementType.ItemId ? e.AsItemId() : default; return e.Type == YamlAssetPath.ElementType.ItemId; }","tryCatchPattern":"try { id = element.AsItemId(); }\ncatch (InvalidOperationException ex) { logger.Error(ex, \"Path element is not an ItemId\"); }","preventionTips":["Check ElementType before extracting values","Only expect ItemIds on collection elements","Cover member and item paths in unit tests"],"tags":["yaml","paths","type-mismatch","union-type"],"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-15T23:17:13.987Z"}