stride3d/stride · error · InvalidOperationException
The given does not correspond to any existing part.
Error message
The given {nameof(parent.Id)} does not correspond to any existing part. What it means
SceneEditorController.AddPart resolves the parent part (entity or scene) game-side via FindPart and throws InvalidOperationException when the parent id resolves to nothing. This guards against attaching a new game-side entity under a parent that no longer exists in the editor's part registry.
Solutions
- Verify the parent part still exists in the hierarchy before invoking AddPart.
- Reload/refresh the asset-side view model so its Id matches the currently loaded game-side scene.
- Ensure the parent is a SceneRootViewModel when the target parent is a scene, so the LoadEntity branch is taken instead.
Example fix
// before
controller.AddPart(newPartViewModel, parentViewModel); // parent may be stale
// after
if (controller.FindPart(parentViewModel.Id) == null && !(parentViewModel is SceneRootViewModel))
return; // parent no longer exists, abort add
controller.AddPart(newPartViewModel, parentViewModel); Defensive patterns
Strategy: validation
Validate before calling
if (!(parent is SceneRootViewModel) && controller.FindPart(parent.Id) == null)
return; // parent part no longer exists
await controller.AddPart(newPart, parent); Type guard
static bool ParentExists(SceneEditorController c, AbsoluteId id) => c.FindPart(id) != null;
Try / catch
try { await controller.AddPart(part, parent); }
catch (InvalidOperationException ex) when (ex.Message.Contains("does not correspond to any existing part")) { await RefreshHierarchyAndRetryAsync(part, parent); } Prevention
- Keep the asset-side hierarchy and game-side parts in sync; refresh after deletes.
- Check parent existence before programmatic adds.
- Route scene parents through the SceneRootViewModel path.
When it happens
Trigger: AddPart called with a parent whose AbsoluteId (AssetId + ObjectId) does not match any registered part — e.g. FindPart(parent.Id) returns null while the parent is not a SceneRootViewModel (which would route through LoadEntity instead).
Common situations: Adding an entity under an entity that was just deleted or unloaded; ids stale after asset reload; referencing a part from a different scene asset than the one loaded.
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
- The given does not correspond to any existing part.
- Cannot change the name of a
- No scene match the given
- Simulated GamePad does not exist
- Simulated Keyboard does not exist
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/7d390e1e5ca73e40.
Report an issue: GitHub.
Appendix: source
Thrown at sources/editor/Stride.Assets.Presentation/AssetEditors/SceneEditor/Services/SceneEditorController.cs:61
/// <inheritdoc />
/// <seealso cref="SceneEditorGame.LoadEntity"/>
public override Task AddPart([NotNull] EntityHierarchyElementViewModel parent, Entity assetSidePart)
{
EnsureAssetAccess();
var gameSidePart = ClonePartForGameSide(parent.Asset.Asset, assetSidePart);
return InvokeAsync(() =>
{
Logger.Debug($"Adding entity {assetSidePart.Id} to game-side scene");
if (parent is SceneRootViewModel)
{
Game.LoadEntity(gameSidePart, parent.Id.ObjectId);
}
else
{
var parentEntity = (Entity)FindPart(parent.Id);
if (parentEntity == null)
throw new InvalidOperationException($"The given {nameof(parent.Id)} does not correspond to any existing part.");
GameSideNodeContainer.GetNode(parentEntity.Transform.Children).Add(gameSidePart.Transform);
}
});
}
/// <inheritdoc />
/// <seealso cref="SceneEditorGame.UnloadEntity"/>
public override Task RemovePart([NotNull] EntityHierarchyElementViewModel parent, Entity assetSidePart)
{
EnsureAssetAccess();
return InvokeAsync(() =>
{
Logger.Debug($"Removing entity {assetSidePart.Id} from game-side scene");
var partId = new AbsoluteId(parent.Id.AssetId, assetSidePart.Id);
var part = (Entity)FindPart(partId);
if (part == null)View on GitHub (pinned to 96fad776d2)