{"record":{"id":"2b1288981cd6a73d","repo":"stride3d/stride","slug":"the-given-assetsidepart-id-does-not-correspond-to-any","errorCode":null,"errorMessage":"The given assetSidePart.Id does not correspond to any existing part.","messagePattern":"The given assetSidePart\\.Id does not correspond to any existing part\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/editor/Stride.Assets.Presentation/AssetEditors/UIEditor/Services/UIEditorController.cs","lineNumber":256,"sourceCode":"                        }\n                        GameSideNodeContainer.GetNode(contentControl)[nameof(contentControl.Content)].Update(gameSidePart);\n                    }\n                }\n            });\n        }\n\n        /// <inheritdoc />\n        public override Task RemovePart([NotNull] UIHierarchyItemViewModel parent, UIElement assetSidePart)\n        {\n            EnsureAssetAccess();\n\n            return InvokeAsync(() =>\n            {\n                Logger.Debug($\"Removing element {assetSidePart.Id} from game-side scene\");\n                var partId = new AbsoluteId(AssetId.Empty, assetSidePart.Id);\n                var part = (UIElement)FindPart(partId);\n                if (part == null)\n                    throw new InvalidOperationException($\"The given {nameof(assetSidePart.Id)} does not correspond to any existing part.\");\n\n                var parentId = (parent as UIElementViewModel)?.Id;\n                if (parentId == null)\n                {\n                    RootElements.Remove(assetSidePart.Id);\n                }\n                else\n                {\n                    var parentElement = (UIElement)FindPart(parentId.Value);\n                    if (parentElement == null)\n                        throw new InvalidOperationException($\"The given {nameof(parentId)} does not correspond to any existing part.\");\n\n                    var panel = parentElement as Panel;\n                    var contentControl = parentElement as ContentControl;\n                    if (panel != null)\n                    {\n                        var i = panel.Children.IndexOf(part);\n                        GameSideNodeContainer.GetNode(panel.Children).Remove(part, new NodeIndex(i));","sourceCodeStart":238,"sourceCodeEnd":274,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/editor/Stride.Assets.Presentation/AssetEditors/UIEditor/Services/UIEditorController.cs#L238-L274","documentation":"UIEditorController.RemovePart throws this InvalidOperationException when assetSidePart.Id cannot be resolved to a game-side UIElement via FindPart. Removing an element with no game-side mirror is treated as a logic error rather than a no-op, because it indicates the asset-side and game-side trees have diverged.","triggerScenarios":"Calling RemovePart with an id that was already removed, never added, or belongs to another asset; RemovePart invoked twice for the same element (duplicate delete events); game-side creation previously failed so the mirror entry is missing.","commonSituations":"Delete handlers firing twice, deletion during undo/redo replay with stale ids, scripts caching element ids across asset reloads.","solutions":["Check that the part id exists in the view model tree before calling RemovePart.","Make deletion idempotent on the caller side: track already-removed ids and skip repeats.","Refresh id references after undo/redo or asset reload.","Ensure AddPart succeeded before attempting to remove the same part."],"exampleFix":"// before\ncontroller.RemovePart(part, parent);\n// after\nif (removedIds.Add(part.Id))\n    controller.RemovePart(part, parent);\n","handlingStrategy":"validation","validationCode":"bool partExists = viewModel.TreeRoot.Flatten().Any(e => e.Id == part.Id);\nif (!partExists) return; // nothing to remove, skip","typeGuard":"UIElementViewModel FindLivePart(Id id) => viewModel.TreeRoot.Flatten().FirstOrDefault(e => e.Id == id);","tryCatchPattern":"try { controller.RemovePart(part, parent); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"does not correspond to any existing part\")) { /* already removed; ignore */ }","preventionTips":["Make delete commands idempotent (track already-removed ids).","Debounce or guard duplicate delete events.","Refresh id references after undo/redo or reload.","Only remove parts whose add completed successfully."],"tags":["csharp","stride","ui-editor","entity-not-found"],"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-15T23:17:13.987Z"}