{"record":{"id":"88356a1803ee2f76","repo":"stride3d/stride","slug":"the-value-must-be-null-when-type-is-elementtype-target","errorCode":null,"errorMessage":"The value must be null when type is ElementType.Target.","messagePattern":"The value must be null when type is ElementType\\.Target\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"sources/presentation/Stride.Core.Quantum/GraphNodePath.cs","lineNumber":446,"sourceCode":"                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":428,"sourceCodeEnd":459,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/presentation/Stride.Core.Quantum/GraphNodePath.cs#L428-L459","documentation":"GraphNodePath.PushElement throws ArgumentException when ElementType.Target is requested but the element value is not null. A Target path segment carries no payload; it is a marker, so any non-null value is invalid input.","triggerScenarios":"Calling PushTarget via the generic Push API with a non-null object (e.g. path.Push(someValue, ElementType.Target)) instead of null.","commonSituations":"Generic path-building code that forwards the same value to Member/Target/Index cases; ported code from other path APIs where Target carries a value.","solutions":["Pass null explicitly when pushing an ElementType.Target segment","Use the parameterless PushTarget() helper instead of the generic Push","Add an assertion that value is null before calling Push with Target","Catch ArgumentException during path construction"],"exampleFix":"// before\npath.Push(targetObj, ElementType.Target);\n// after\npath.PushTarget();","handlingStrategy":"type-guard","validationCode":"if (elementValue != null) throw new ArgumentException(\"Target path element must be null\");","typeGuard":"bool IsValidTargetElement(object? v) => v is null;","tryCatchPattern":"try { path.Push(value, ElementType.Target); } catch (ArgumentException ex) { logger.LogError(ex, \"Invalid target path element\"); }","preventionTips":["Use the parameterless PushTarget() helper","Never reuse a single Push call across Member/Target/Index cases","Document that Target segments carry no payload"],"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"}