{"record":{"id":"7d390e1e5ca73e40","repo":"stride3d/stride","slug":"the-given-nameof-parent-id-does-not-correspond-to-any-7d390e","errorCode":null,"errorMessage":"The given {nameof(parent.Id)} does not correspond to any existing part.","messagePattern":"The given (.+?) does not correspond to any existing part\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/editor/Stride.Assets.Presentation/AssetEditors/SceneEditor/Services/SceneEditorController.cs","lineNumber":61,"sourceCode":"        /// <inheritdoc />\n        /// <seealso cref=\"SceneEditorGame.LoadEntity\"/>\n        public override Task AddPart([NotNull] EntityHierarchyElementViewModel parent, Entity assetSidePart)\n        {\n            EnsureAssetAccess();\n\n            var gameSidePart = ClonePartForGameSide(parent.Asset.Asset, assetSidePart);\n            return InvokeAsync(() =>\n            {\n                Logger.Debug($\"Adding entity {assetSidePart.Id} to game-side scene\");\n                if (parent is SceneRootViewModel)\n                {\n                    Game.LoadEntity(gameSidePart, parent.Id.ObjectId);\n                }\n                else\n                {\n                    var parentEntity = (Entity)FindPart(parent.Id);\n                    if (parentEntity == null)\n                        throw new InvalidOperationException($\"The given {nameof(parent.Id)} does not correspond to any existing part.\");\n\n                    GameSideNodeContainer.GetNode(parentEntity.Transform.Children).Add(gameSidePart.Transform);\n                }\n            });\n        }\n\n        /// <inheritdoc />\n        /// <seealso cref=\"SceneEditorGame.UnloadEntity\"/>\n        public override Task RemovePart([NotNull] EntityHierarchyElementViewModel parent, Entity assetSidePart)\n        {\n            EnsureAssetAccess();\n\n            return InvokeAsync(() =>\n            {\n                Logger.Debug($\"Removing entity {assetSidePart.Id} from game-side scene\");\n                var partId = new AbsoluteId(parent.Id.AssetId, assetSidePart.Id);\n                var part = (Entity)FindPart(partId);\n                if (part == null)","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/editor/Stride.Assets.Presentation/AssetEditors/SceneEditor/Services/SceneEditorController.cs#L43-L79","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"// before\ncontroller.AddPart(newPartViewModel, parentViewModel); // parent may be stale\n// after\nif (controller.FindPart(parentViewModel.Id) == null && !(parentViewModel is SceneRootViewModel))\n    return; // parent no longer exists, abort add\ncontroller.AddPart(newPartViewModel, parentViewModel);","handlingStrategy":"validation","validationCode":"if (!(parent is SceneRootViewModel) && controller.FindPart(parent.Id) == null)\n    return; // parent part no longer exists\nawait controller.AddPart(newPart, parent);","typeGuard":"static bool ParentExists(SceneEditorController c, AbsoluteId id) => c.FindPart(id) != null;","tryCatchPattern":"try { await controller.AddPart(part, parent); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"does not correspond to any existing part\")) { await RefreshHierarchyAndRetryAsync(part, parent); }","preventionTips":["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."],"tags":["entity-not-found","scene-editor","parent-lookup"],"backgroundTag":"entity-not-found","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}