{"record":{"id":"089a1bef6bfb3bb6","repo":"stride3d/stride","slug":"an-error-occurred-while-removing-an-item-to-the-node-see-the-089a1b","errorCode":null,"errorMessage":"An error occurred while removing an item to the node, see the inner exception for more information.","messagePattern":"An error occurred while removing an item to the node, see the inner exception for more information\\.","errorType":"exception","errorClass":"NodePresenterException","httpStatus":null,"severity":"error","filePath":"sources/presentation/Stride.Core.Presentation.Quantum/Presenters/RootNodePresenter.cs","lineNumber":100,"sourceCode":"            }\n            catch (Exception e)\n            {\n                throw new NodePresenterException(\"An error occurred while adding an item to the node, see the inner exception for more information.\", e);\n            }\n        }\n\n        public override void RemoveItem(object value, NodeIndex index)\n        {\n            if (!RootNode.IsEnumerable)\n                throw new NodePresenterException($\"{nameof(RootNodePresenter)}.{nameof(RemoveItem)} cannot be invoked on objects that are not collection.\");\n\n            try\n            {\n                RootNode.Remove(value, index);\n            }\n            catch (Exception e)\n            {\n                throw new NodePresenterException(\"An error occurred while removing an item to the node, see the inner exception for more information.\", e);\n            }\n        }\n\n        public override NodeAccessor GetNodeAccessor()\n        {\n            return new NodeAccessor(RootNode, NodeIndex.Empty);\n        }\n\n        private void OnItemChanging(object? sender, ItemChangeEventArgs e)\n        {\n            RaiseValueChanging(Value);\n        }\n\n        private void OnItemChanged(object? sender, ItemChangeEventArgs e)\n        {\n            Refresh();\n            RaiseValueChanged(Value);\n        }","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/presentation/Stride.Core.Presentation.Quantum/Presenters/RootNodePresenter.cs#L82-L118","documentation":"RootNodePresenter.RemoveItem wraps RootNode.Remove(value, index) and rethrows failures as NodePresenterException with the original exception as InnerException. It signals that removing an item from the root node failed. The actual error is the inner exception.","triggerScenarios":"Calling RootNodePresenter.RemoveItem(value, index) when RootNode.Remove(value, index) throws — item missing, read-only collection, or model-side validation failure.","commonSituations":"Deleting a root-level dictionary/list entry that was already removed or never existed; fixed-size arrays exposed as root collections; concurrent modification of the underlying model.","solutions":["Check the InnerException for the real cause.","Verify the item exists at the given NodeIndex before removal.","Ensure the root collection supports removal (not read-only/fixed-size).","Re-sync the presenter with the current model state if it is stale."],"exampleFix":"// before\nrootNodePresenter.RemoveItem(value, index); // throws if already removed\n// after\nif (rootNode.IsEnumerable && rootNode.Content is IDictionary dict && dict.Contains(index.Value))\n    rootNodePresenter.RemoveItem(value, index);","handlingStrategy":"try-catch","validationCode":"if (!rootNodePresenter.RootNode.IsEnumerable)\n    throw new InvalidOperationException(\"Root node is not enumerable; RemoveItem will fail.\");","typeGuard":"static bool CanRemoveFromRoot(RootNodePresenter p) => p != null && p.RootNode?.IsEnumerable == true;","tryCatchPattern":"try\n{\n    rootNodePresenter.RemoveItem(value, index);\n}\ncatch (NodePresenterException ex)\n{\n    logger.Error(ex.InnerException, \"RemoveItem failed on root node\");\n}","preventionTips":["Check the item/index exists before removing.","Avoid removing from fixed-size or read-only root collections.","Guard against concurrent modification of the underlying model."],"tags":["dotnet","root-node","collection","wrapped-exception"],"backgroundTag":"wrapped-exception-remove-item-failed","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"}