{"record":{"id":"ddeb203fcdf62ade","repo":"stride3d/stride","slug":"parent-cannot-be-null-ddeb20","errorCode":null,"errorMessage":"parent cannot be null","messagePattern":"parent cannot be null","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/editor/Stride.Assets.Presentation/AssetEditors/EntityHierarchyEditor/ViewModels/EntityFolderViewModel.cs","lineNumber":195,"sourceCode":"\n            if (Editor.UndoRedoService.UndoRedoInProgress)\n            {\n                name = newName;\n                return;\n            }\n\n            using (var transaction = Editor.UndoRedoService.CreateTransaction())\n            {\n                // We need to update the name first so that the Path properties is consistent\n                var oldName = name;\n                name = newName;\n\n                foreach (var entity in InnerSubEntities)\n                {\n                    var node = Editor.NodeContainer.GetOrCreateNode(entity.EntityDesign);\n                    // In this case, the parent is either the current folder or a subfolder in between\n                    var parent = (EntityFolderViewModel)entity.Parent;\n                    if (parent == null) throw new InvalidOperationException($\"{nameof(parent)} cannot be null\");\n                    node[nameof(EntityDesign.Folder)].Update(parent.Path);\n                }\n\n                if (Parent == null) throw new InvalidOperationException($\"{nameof(Parent)} cannot be null\");\n                var operation = new EntityFolderOperation(Asset, EntityFolderOperation.Action.FolderRenamed, Path, oldName, Parent.Owner.Id);\n                Editor.UndoRedoService.PushOperation(operation);\n                Editor.UndoRedoService.SetName(transaction, $\"Rename folder '{oldName}' to '{newName}'\");\n            }\n        }\n    }\n}\n","sourceCodeStart":177,"sourceCodeEnd":207,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/editor/Stride.Assets.Presentation/AssetEditors/EntityHierarchyEditor/ViewModels/EntityFolderViewModel.cs#L177-L207","documentation":"Inside EntityFolderViewModel.UpdateName (called from the Name setter), each contained entity's Folder design property is updated from its view-model parent; a null cast parent means the entity's view-model tree is inconsistent, so an InvalidOperationException is thrown rather than writing a wrong folder path.","triggerScenarios":"Renaming a folder when one of its InnerSubEntities has a null Parent view-model (entity attached to folder but not to a parent node in the view-model tree).","commonSituations":"Hierarchy partially built or modified concurrently; entities reparented outside the transaction system before the rename.","solutions":["Fix the view-model tree so every entity in InnerSubEntities has a non-null parent","Remove/re-attach orphaned entities before renaming the folder","Inspect entity.Parent in the debugger to find the inconsistent node"],"exampleFix":"// before\nfolder.Name = newName; // throws if an entity has null parent\n// after\nforeach (var e in folder.InnerSubEntities)\n    if (e.Parent == null) throw new InvalidOperationException($\"Entity {e.Name} is not attached\");\nfolder.Name = newName;","handlingStrategy":"validation","validationCode":"bool canRename = folder.InnerSubEntities.All(e => e.Parent != null);\nif (canRename) folder.Name = newName;","typeGuard":null,"tryCatchPattern":"try { folder.Name = newName; }\ncatch (InvalidOperationException ex) { /* repair inconsistent entity tree */ }","preventionTips":["Keep entity view-model parenting consistent via editor APIs only","Avoid manual manipulation of sub-entity collections"],"tags":["csharp","stride","hierarchy","invariant"],"backgroundTag":"internal-invariant-violation","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"}