stride3d/stride · error · InvalidOperationException
The folder being deleted is not empty.
Error message
The folder being deleted is not empty.
What it means
EntityFolderViewModel.Delete() refuses to delete a folder that still contains entities (directly or in subfolders, via InnerSubEntities). Stride requires folders to be emptied first so the undo/redo operation only has to record a simple folder deletion. Thrown as InvalidOperationException before any hierarchy mutation happens.
Solutions
- Move or delete all entities inside the folder (and subfolders) before calling Delete()
- Check InnerSubEntities.Any() before calling Delete and inform the user the folder must be empty
- Recursively delete subfolders after emptying them, then delete the parent folder
Example fix
// before
folder.Delete(); // throws if not empty
// after
if (!folder.InnerSubEntities.Any())
folder.Delete();
else
// move/delete entities first or notify the user Defensive patterns
Strategy: validation
Validate before calling
if (folder.InnerSubEntities.Any()) throw new InvalidOperationException("Move or delete entities before deleting this folder.");
folder.Delete(); Try / catch
try { folder.Delete(); }
catch (InvalidOperationException) { /* prompt user to empty the folder */ } Prevention
- Always check InnerSubEntities.Any() before Delete
- Recursively empty subfolders first
- Surface the empty-folder requirement in UI before enabling the delete command
When it happens
Trigger: Calling Delete() on an EntityFolderViewModel whose InnerSubEntities collection is non-empty, e.g. deleting a folder that has entities placed in it or in any nested subfolder.
Common situations: User-facing 'delete folder' command invoked on a populated folder; scripted batch cleanup of an entity hierarchy that forgot to move or delete child entities first.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- MicroThread was already started before.
- The entity to insert has already been destroyed
- Cannot change the name of a EntityHierarchyRootViewModel…
- and cannot both be empty.
- There must be two and only two input values for Int2.
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/9dddd662aa1e31fa.
Report an issue: GitHub.
Appendix: source
Thrown at sources/editor/Stride.Assets.Presentation/AssetEditors/EntityHierarchyEditor/ViewModels/EntityFolderViewModel.cs:132
var indexInFolder = 0;
var i = 0;
foreach (var entity in entityCollection)
{
if (i++ == indexInEntity)
break;
if (string.Equals(entity.Folder, Path, FolderCase))
++indexInFolder;
}
return indexInFolder;
}
/// <summary>
/// Deletes this folder. The folder must not contain any entity before being deleted.
/// </summary>
public void Delete()
{
if (InnerSubEntities.Any()) throw new InvalidOperationException("The folder being deleted is not empty.");
var path = Path;
var ownerId = Owner.Id;
if (Parent == null) throw new InvalidOperationException($"{nameof(Parent)} cannot be null");
Parent.Folders.Remove(this);
if (!Editor.UndoRedoService.UndoRedoInProgress)
{
var operation = new EntityFolderOperation(Asset, EntityFolderOperation.Action.FolderDeleted, path, ownerId);
Editor.UndoRedoService.PushOperation(operation);
}
}
/// <inheritdoc />
public override GraphNodePath GetNodePath()
{
return Owner.GetNodePath();
}
private bool CanUpdateName([CanBeNull] string newName)View on GitHub (pinned to 96fad776d2)