{"record":{"id":"f26cbd97888923f8","repo":"stride3d/stride","slug":"this-instance-doesn-t-contain-any-path-use-push-methods-to","errorCode":null,"errorMessage":"This instance doesn't contain any path. Use Push() methods to populate paths","messagePattern":"This instance doesn't contain any path\\. Use Push\\(\\) methods to populate paths","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core.Reflection/MemberPath.cs","lineNumber":231,"sourceCode":"    {\n        if (items.Count > 0)\n        {\n            items.RemoveAt(items.Count - 1);\n        }\n    }\n\n    public bool Apply(object rootObject, MemberPathAction actionType, object? value)\n    {\n        ArgumentNullException.ThrowIfNull(rootObject);\n        if (rootObject.GetType().IsValueType) throw new ArgumentException(\"Value type for root objects are not supported\", nameof(rootObject));\n        if (actionType != MemberPathAction.ValueSet && actionType != MemberPathAction.CollectionAdd && value != null)\n        {\n            throw new ArgumentException(\"Value must be null for action != (MemberActionType.SetValue || MemberPathAction.CollectionAdd)\");\n        }\n\n        if (items == null || items.Count == 0)\n        {\n            throw new InvalidOperationException(\"This instance doesn't contain any path. Use Push() methods to populate paths\");\n        }\n\n        var lastItem = items[^1];\n        switch (actionType)\n        {\n            case MemberPathAction.CollectionAdd:\n                if (lastItem is not CollectionPathItem)\n                {\n                    throw new ArgumentException(\"Invalid path [{0}] for action [{1}]. Expecting last path to be a collection item\".ToFormat(this, actionType));\n                }\n                break;\n            case MemberPathAction.CollectionRemove:\n                if (lastItem is not (CollectionPathItem or ArrayPathItem))\n                {\n                    throw new ArgumentException(\"Invalid path [{0}] for action [{1}]. Expecting last path to be a collection/array item\".ToFormat(this, actionType));\n                }\n                break;\n","sourceCodeStart":213,"sourceCodeEnd":249,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core.Reflection/MemberPath.cs#L213-L249","documentation":"A MemberPath instance must have at least one path segment, populated via its Push() methods, before Apply() can target anything. Apply() reads items[^1] (the last segment) to decide where the action lands; with an empty path there is nothing to act on, so it throws InvalidOperationException.","triggerScenarios":"Creating a new MemberPath() (or using the default-constructed instance) and immediately calling Apply(root, MemberPathAction.ValueSet, value) without calling Push/ Push Member / Push CollectionItem first.","commonSituations":"Building paths dynamically where an early return or failed condition skipped all Push calls; deserializing a MemberPath whose items list was empty; unit-test scaffolding that forgot path construction.","solutions":["Populate the path before applying: call Push(MemberDescriptor/PropertyInfo) or Push(CollectionPathItem...) at least once.","Guard with a check like if (path.ItemCount == 0) before calling Apply, and build the path in that branch.","If the path was deserialized, verify the source data actually contained path segments."],"exampleFix":"// before\nvar path = new MemberPath();\npath.Apply(root, MemberPathAction.ValueSet, 42);\n// after\nvar path = new MemberPath();\npath.Push(myObjectPropertyDescriptor);\npath.Apply(root, MemberPathAction.ValueSet, 42);","handlingStrategy":"validation","validationCode":"if (path.ItemCount == 0)\n    throw new InvalidOperationException(\"MemberPath is empty; push at least one segment before Apply.\");","typeGuard":null,"tryCatchPattern":"try { path.Apply(root, action, value); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"doesn't contain any path\")) { /* build the path first */ }","preventionTips":["Build MemberPath instances through factory methods (FromMemberPath etc.) rather than raw construction.","Assert path length > 0 in tests for path-mutation helpers."],"tags":["invalid-state","reflection","csharp"],"backgroundTag":"empty-required-field","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"}