{"record":{"id":"f3ced18b7127bb23","repo":"stride3d/stride","slug":"the-corresponding-ui-element-could-not-be-found-in-the-f3ced1","errorCode":null,"errorMessage":"The corresponding UI element could not be found in the library.","messagePattern":"The corresponding UI element could not be found in the library\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/editor/Stride.Assets.Presentation/AssetEditors/UIEditor/ViewModels/UIElementFromSystemLibrary.cs","lineNumber":31,"sourceCode":"using Stride.UI;\nusing Stride.Core.Presentation.ViewModels;\n\nnamespace Stride.Assets.Presentation.AssetEditors.UIEditor.ViewModels\n{\n    internal sealed class UIElementFromSystemLibrary : ViewModelBase, IUIElementFactory\n    {\n        private readonly UILibraryViewModel library;\n        private readonly Guid id;\n\n        public UIElementFromSystemLibrary([NotNull] IViewModelServiceProvider serviceProvider, [NotNull] UILibraryViewModel library, Guid id)\n            : base(serviceProvider)\n        {\n            this.library = library;\n            this.id = id;\n\n            UIElementDesign element;\n            if (!library.Asset.Hierarchy.Parts.TryGetValue(id, out element))\n                throw new InvalidOperationException(\"The corresponding UI element could not be found in the library.\");\n\n            Type = element.UIElement.GetType();\n            Category = TypeDescriptorFactory.Default.AttributeRegistry.GetAttribute<Core.DisplayAttribute>(Type)?.Category ?? \"Misc.\";\n        }\n\n        public string Name => Type.Name;\n\n        public Type Type { get; }\n\n        public string Category { get; }\n\n        [NotNull]\n        public AssetCompositeHierarchyData<UIElementDesign, UIElement> Create(UIAssetBase targetAsset)\n        {\n            // Create a clone without linking to the library\n            var flags = SubHierarchyCloneFlags.GenerateNewIdsForIdentifiableObjects | SubHierarchyCloneFlags.RemoveOverrides;\n            var clonedHierarchy = UIAssetPropertyGraph.CloneSubHierarchies(library.Session.AssetNodeContainer, library.Asset, id.Yield(), flags, out Dictionary<Guid, Guid> _);\n            foreach (var part in clonedHierarchy.Parts.Values)","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/editor/Stride.Assets.Presentation/AssetEditors/UIEditor/ViewModels/UIElementFromSystemLibrary.cs#L13-L49","documentation":"Thrown in the UIElementFromSystemLibrary constructor when the given id cannot be found in the system UI library asset's Hierarchy.Parts. The constructor needs the part to determine Type and Category, so a missing id makes the object impossible to construct.","triggerScenarios":"Constructing UIElementFromSystemLibrary(library, id) with an id that is not a key of library.Asset.Hierarchy.Parts — e.g. an id from a different library version or a typo'd/removed system element id.","commonSituations":"Engine upgrade where built-in library element ids changed; hand-written editor scripts referencing removed system UI elements; deserialized editor state holding ids from an older Stride version.","solutions":["Use a valid id that exists in the current system library (enumerate library.Asset.Hierarchy.Parts to pick one).","Restore/upgrade the library asset so the expected id exists.","Guard with TryGetValue before constructing and handle the missing-element case (skip, log, or prompt the user)."],"exampleFix":"// before\nvar vm = new UIElementFromSystemLibrary(systemLibrary, oldId);\n// after\nif (!systemLibrary.Asset.Hierarchy.Parts.TryGetValue(oldId, out var design))\n    return null; // or prompt user to re-pick\nvar vm = new UIElementFromSystemLibrary(systemLibrary, oldId);","handlingStrategy":"validation","validationCode":"bool exists = library?.Asset?.Hierarchy?.Parts.TryGetValue(id, out _) == true;","typeGuard":"static bool SystemLibraryContains(UILibraryViewModel library, Guid id) => library?.Asset?.Hierarchy?.Parts.ContainsKey(id) ?? false;","tryCatchPattern":"try { var vm = new UIElementFromSystemLibrary(library, id); } catch (InvalidOperationException ex) { /* fall back to re-picking element */ }","preventionTips":["Enumerate library.Asset.Hierarchy.Parts to obtain valid ids instead of hardcoding them.","Re-check system library ids after engine upgrades.","Handle deserialized legacy ids by mapping them to current library entries."],"tags":["stride","ui-library","stale-reference","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"}