{"record":{"id":"6e1031459dfa4265","repo":"stride3d/stride","slug":"this-item-is-not-a-member","errorCode":null,"errorMessage":"This item is not a Member","messagePattern":"This item is not a Member","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/assets/Stride.Core.Assets/Yaml/YamlAssetPath.cs","lineNumber":68,"sourceCode":"\n        /// <summary>\n        /// Initializes a new instance of the <see cref=\"Element\"/> structure.\n        /// </summary>\n        /// <param name=\"type\">The type of element.</param>\n        /// <param name=\"value\">The value of the element.</param>\n        public Element(ElementType type, object value)\n        {\n            Type = type;\n            Value = value;\n        }\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        }","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/assets/Stride.Core.Assets/Yaml/YamlAssetPath.cs#L50-L86","documentation":"YamlAssetPath.Element is a tagged union: its Value meaning depends on Type (Member name string, Index int, ItemId Guid). AsMember() casts Value to string and throws InvalidOperationException if the element's Type is not ElementType.Member.","triggerScenarios":"Calling AsMember() on a path element whose ElementType is Index or ItemId — e.g. iterating path elements and assuming all are members when a path also contains collection indices or item ids.","commonSituations":"Editor/plugin code walking YamlAssetPath elements to build UI breadcrumbs or fixups; scripts mis-parsing paths produced for list items or dictionary entries; off-by-one in path construction so a member call lands on an index element.","solutions":["Check item.Type == ElementType.Member before calling AsMember()","Use switch/if on ElementType to dispatch to AsMember/AsItemId/Index appropriately","Fix the code that built the YamlAssetPath so member elements are pushed with PushMember","Log the element Type to find where the wrong element was appended"],"exampleFix":"// before\nstring name = element.AsMember();\n// after\nstring name = element.Type == YamlAssetPath.ElementType.Member\n    ? element.AsMember()\n    : throw new InvalidOperationException($\"Unexpected element type {element.Type}\");","handlingStrategy":"type-guard","validationCode":"if (element.Type != YamlAssetPath.ElementType.Member)\n    throw new InvalidOperationException($\"Element is {element.Type}, expected Member\");","typeGuard":"bool TryAsMember(in YamlAssetPath.Element e, out string name)\n{ name = e.Type == YamlAssetPath.ElementType.Member ? e.AsMember() : null; return name is not null; }","tryCatchPattern":"try { name = element.AsMember(); }\ncatch (InvalidOperationException ex) { logger.Error(ex, \"Path element is not a member\"); continue; }","preventionTips":["Dispatch on ElementType before reading values","Push member elements only via PushMember","Test path round-trips for lists/dictionaries, not just members"],"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"}