stride3d/stride · error · InvalidOperationException
parent cannot be null
Error message
parent cannot be null
What it means
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.
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
Example fix
// before
folder.Name = newName; // throws if an entity has null parent
// after
foreach (var e in folder.InnerSubEntities)
if (e.Parent == null) throw new InvalidOperationException($"Entity {e.Name} is not attached");
folder.Name = newName; Defensive patterns
Strategy: validation
Validate before calling
bool canRename = folder.InnerSubEntities.All(e => e.Parent != null); if (canRename) folder.Name = newName;
Try / catch
try { folder.Name = newName; }
catch (InvalidOperationException ex) { /* repair inconsistent entity tree */ } Prevention
- Keep entity view-model parenting consistent via editor APIs only
- Avoid manual manipulation of sub-entity collections
When it happens
Trigger: 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).
Common situations: Hierarchy partially built or modified concurrently; entities reparented outside the transaction system before the rename.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- is not contained in a hierarchy.
- Entity shouldn't have a parent.
- IsObjectReference returned true for an object that is not…
- and cannot both be empty.
- Internal error, the collection has already muted to a…
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/ddeb203fcdf62ade.
Report an issue: GitHub.
Appendix: source
Thrown at sources/editor/Stride.Assets.Presentation/AssetEditors/EntityHierarchyEditor/ViewModels/EntityFolderViewModel.cs:195
if (Editor.UndoRedoService.UndoRedoInProgress)
{
name = newName;
return;
}
using (var transaction = Editor.UndoRedoService.CreateTransaction())
{
// We need to update the name first so that the Path properties is consistent
var oldName = name;
name = newName;
foreach (var entity in InnerSubEntities)
{
var node = Editor.NodeContainer.GetOrCreateNode(entity.EntityDesign);
// In this case, the parent is either the current folder or a subfolder in between
var parent = (EntityFolderViewModel)entity.Parent;
if (parent == null) throw new InvalidOperationException($"{nameof(parent)} cannot be null");
node[nameof(EntityDesign.Folder)].Update(parent.Path);
}
if (Parent == null) throw new InvalidOperationException($"{nameof(Parent)} cannot be null");
var operation = new EntityFolderOperation(Asset, EntityFolderOperation.Action.FolderRenamed, Path, oldName, Parent.Owner.Id);
Editor.UndoRedoService.PushOperation(operation);
Editor.UndoRedoService.SetName(transaction, $"Rename folder '{oldName}' to '{newName}'");
}
}
}
}
View on GitHub (pinned to 96fad776d2)