{"record":{"id":"8b48b66b674e9c82","repo":"stride3d/stride","slug":"the-value-must-be-a-non-null-string-when-type-is-elementtype","errorCode":null,"errorMessage":"The value must be a non-null string when type is ElementType.Member.","messagePattern":"The value must be a non-null string when type is ElementType\\.Member\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"sources/presentation/Stride.Core.Quantum/GraphNodePath.cs","lineNumber":441,"sourceCode":"                    {\n                        var objectRefererence = enumerableReference!.Single(x => Equals(x.Index, index));\n                        node = objectRefererence.TargetNode;\n                    }\n                    break;\n                default:\n                    throw new ArgumentOutOfRangeException();\n            }\n        }\n        return memberPath;\n    }\n\n    private void PushElement(object? elementValue, ElementType type)\n    {\n        switch (type)\n        {\n            case ElementType.Member:\n                if (elementValue is not string name)\n                    throw new ArgumentException(\"The value must be a non-null string when type is ElementType.Member.\");\n                path.Add(NodePathElement.CreateMember(name));\n                break;\n            case ElementType.Target:\n                if (elementValue != null)\n                    throw new ArgumentException(\"The value must be null when type is ElementType.Target.\");\n                path.Add(NodePathElement.CreateTarget());\n                break;\n            case ElementType.Index:\n                if (!(elementValue is NodeIndex))\n                    throw new ArgumentException(\"The value must be an Index when type is ElementType.Index.\");\n                path.Add(NodePathElement.CreateIndex((NodeIndex)elementValue));\n                break;\n            default:\n                throw new ArgumentOutOfRangeException(nameof(type));\n        }\n    }\n}\n","sourceCodeStart":423,"sourceCodeEnd":459,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/presentation/Stride.Core.Quantum/GraphNodePath.cs#L423-L459","documentation":"A validation guard in GraphNodePath.PushElement: when the ElementType is Member, the element value must be a non-null string (the member name). PushMember/PushTarget/PushIndex build the node path by pushing typed elements; pushing a Member element with a non-string value (e.g. an index or object) indicates a path-building bug, so an ArgumentOutOfRangeException with this message is thrown instead of corrupting the path.","triggerScenarios":"Calling PushMember (directly or via Push/PushTarget/PushIndex helpers) with a null or non-string object, e.g. path.Push(null) or passing an enum/int where a member name is expected.","commonSituations":"Building node paths programmatically with variables of type object; refactorings renaming members so the name variable becomes null; copying path code between Member and Index variants.","solutions":["Pass the member name as a string (nameof(Member) or the string constant)","Null-check the name variable before pushing","Use the typed PushMember(string) helper instead of the generic Push(object, ElementType)","Catch ArgumentException at path construction to catch bad inputs early"],"exampleFix":"// before\npath.Push(null, ElementType.Member);\n// after\npath.PushMember(nameof(Model.Name));","handlingStrategy":"type-guard","validationCode":"if (elementValue is not string name) throw new ArgumentException(\"Member path element must be a string\");","typeGuard":"bool IsMemberElement(object? v) => v is string s && !string.IsNullOrEmpty(s);","tryCatchPattern":"try { path.Push(value, ElementType.Member); } catch (ArgumentException ex) { logger.LogError(ex, \"Invalid member path element\"); }","preventionTips":["Use PushMember(nameof(X.Y)) instead of generic Push","Null-check member name variables before path building","Keep path-building code strongly typed"],"tags":["path","argument","quantum"],"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"}