-
Notifications
You must be signed in to change notification settings - Fork 1
NullReferenceException in GetGroupAssets when calling node.GetProductGroup() on freshly created menu items #555
Description
When creating a new menu item in the content tree, the frontend crashes with a NullReferenceException when the navigation template attempts to fetch the associated product group using node.GetProductGroup().
The error originates deep within Dynamicweb.Ecommerce.ProductCatalog.ViewEngine.GetGroupAssets. It appears that for newly created nodes, the core engine attempts to process group assets before they are fully cached or initialized, failing to handle null values gracefully and causing a fatal crash instead of returning an empty model or null.
Steps to Reproduce:
- Use a Dynamicweb 10 environment with Swift.
- Create a brand new menu item in the backend.
- Load the frontend page where the menu is rendered.
- The page will crash with a NullReferenceException.
Stack Trace:
Error executing template "Designs/Swift-v2/Paragraph/Swift-v2_MenuRelatedContent/Menu.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
at Dynamicweb.Ecommerce.ProductCatalog.ViewEngine.GetGroupAssets(MediaViewModelSettings settings, Group group)
at Dynamicweb.Ecommerce.ProductCatalog.ViewEngine.CreateProductGroup(ProductGroupViewModelSettings settings, ViewModelPropertyFiller1 filler, Group group) at Dynamicweb.Ecommerce.ProductCatalog.NavigationTreeViewNodeExtensions.GetProductGroup(NavigationTreeNodeViewModel node) at CompiledRazorTemplates.Dynamic.RazorEngine_0e5740b69a1c4d42979790ac728b7ca8.GetGroupFieldValue(String fieldSystemName, NavigationTreeNodeViewModel node) at CompiledRazorTemplates.Dynamic.RazorEngine_0e5740b69a1c4d42979790ac728b7ca8.ExecuteAsync() at RazorEngine.Templating.TemplateBase.Run(ExecuteContext context, TextWriter reader) at RazorEngine.Templating.RazorEngineCore.RunTemplate(ICompiledTemplate template, TextWriter writer, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.DynamicWrapperService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass23_0.<Run>b__0(TextWriter writer) at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action1 withWriter)
at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, Type modelType, Object model, DynamicViewBag viewBag)
at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
at Dynamicweb.Rendering.Template.RenderRazorTemplate()
Workaround / Additional Context:
Manually clearing the application cache via the backend, immediately resolves the issue, allowing the menu to render properly.