{"record":{"id":"0b74059c9bd190b6","repo":"stride3d/stride","slug":"the-given-nameof-parent-id-does-not-correspond-to-any","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/PrefabEditor/Services/PrefabEditorController.cs","lineNumber":53,"sourceCode":"\n        /// <inheritdoc />\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 PrefabRootViewModel)\n                {\n                    Game.LoadEntity(gameSidePart);\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        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(AssetId.Empty, assetSidePart.Id);\n                var part = (Entity)FindPart(partId);\n                if (part == null)\n                    throw new InvalidOperationException($\"The given {nameof(assetSidePart.Id)} does not correspond to any existing part.\");","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/editor/Stride.Assets.Presentation/AssetEditors/PrefabEditor/Services/PrefabEditorController.cs#L35-L71","documentation":"PrefabEditorController.AddPart throws this InvalidOperationException when the parent part id supplied by the asset-side hierarchy cannot be resolved to an existing game-side Entity via FindPart. It guards an internal consistency assumption: you can only attach a new part's Transform under a parent that already exists in the game-side node container.","triggerScenarios":"Calling AddPart with a parent whose Id is stale, wrong, or whose corresponding entity has not yet been loaded into the game-side scene, so FindPart(parent.Id) returns null.","commonSituations":"Editor scripting or plugin code that holds ids from a previous prefab state; adding a part before its parent entity was loaded; desynchronized asset/game-side views after undo/redo or asset reload.","solutions":["Verify the parent part exists and is loaded before calling AddPart (e.g. resolve it via FindPart yourself).","Refresh the asset-side viewmodel ids so they match the current game-side hierarchy.","Ensure the parent entity was loaded first (correct part-add ordering).","Catch InvalidOperationException and surface a 'parent part not found' message to the user."],"exampleFix":"// before\ncontroller.AddPart(newPart, parentWithStaleId);\n// after\nif (controller.FindPart(parent.Id) != null)\n    controller.AddPart(newPart, parent);\nelse\n    logger.Warn($\"Parent part {parent.Id} not loaded; skipping AddPart\");","handlingStrategy":"validation","validationCode":"if (parent == null || controller.FindPart(parent.Id) == null) throw new ArgumentException($\"Parent part {parent.Id} not found\");","typeGuard":"bool ParentExists(IPartViewModel p) => p?.Id != null && controller.FindPart(p.Id) != null;","tryCatchPattern":"try { controller.AddPart(part, parent); } catch (InvalidOperationException ex) when (ex.Message.Contains(\"does not correspond to any existing part\")) { logger.Warn($\"Parent {parent.Id} missing: {ex.Message}\"); }","preventionTips":["Always load the parent part before adding children","Refresh viewmodels after undo/redo before mutating the hierarchy","Assert parent ids resolve via FindPart in debug builds"],"tags":["stride-editor","prefab","invalid-argument-value","entity-not-found"],"backgroundTag":"record-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"}