Bakersbakebread / Our.Umbraco.NodeDefender

Defend your nodes with honor
2 stars 2 forks source link

It Breaks Content Section in v10.2.0 #2

Open TRexStark opened 1 year ago

TRexStark commented 1 year ago

The package functionality works fine - as far as disabling the renaming of nodes goes - based on my test.

However, when you try to create a new node in the content tree, you get the following error.

Object reference not set to an instance of an object.

at NodeDefender.Handlers.ContentSavingHandler.GetDuplicateErrorMessage() at NodeDefender.Handlers.ContentSavingHandler.HandleDuplicate(IContentBase node, ContentSavingNotification notification) at NodeDefender.Handlers.ContentSavingHandler.Handle(ContentSavingNotification notification) at Umbraco.Cms.Core.Events.EventAggregator.PublishCore(IEnumerable1 allHandlers, INotification notification) at Umbraco.Cms.Core.Events.NotificationHandlerWrapperImpl1.Handle(INotification notification, ServiceFactory serviceFactory, Action2 publish) at Umbraco.Cms.Core.Events.EventAggregator.Publish[TNotification](TNotification notification) at Umbraco.Cms.Core.Events.ScopedNotificationPublisher.PublishCancelable(ICancelableNotification notification) at Umbraco.Cms.Core.Services.ContentService.SaveAndPublish(IContent content, String culture, Int32 userId) at Umbraco.Cms.Web.BackOffice.Controllers.ContentController.PublishInternal(ContentItemSave contentItem, String defaultCulture, String cultureForInvariantErrors, Boolean& wasCancelled, String[]& successfulCultures) at Umbraco.Cms.Web.BackOffice.Controllers.ContentController.PostSaveInternal[TVariant](ContentItemSave contentItem, Func3 saveMethod, Func2 mapToDisplay) at Umbraco.Cms.Web.BackOffice.Controllers.ContentController.PostSave(ContentItemSave contentItem) at lambda_method1453(Closure , Object ) at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask1 actionResultValueTask) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)

nobledm commented 8 months ago

I experienced the same issue (varying Stack Traces but all related to nulls) with Umbraco v12.2.0. Could not use the '. . .' menu at all on any content item regardless of any protection set on them.

I experimented with various arrangements of the appsettings options and discovered that the issue is related to empty/null checks specifically for the DenyDuplicate section of options. When any of them were not explicitly set (excluding Message) it produced an empty collection error and breaks the Back Office Create menu. I was able to avoid the error with setting DenyDuplicate like this:

"DenyDuplicate": {
  "DoctypeAliases": [
    ""
  ],
  "NodeIds": [
    1
  ],
  "NodeKeys": [
    ""
  ],
  "CompositionAliases": [
    ""
  ]
},

Then everything worked like a dream!

EDIT Can't use '0' as a NodeID it turns out :p Changed it to 1 and then it all worked haha. If you use 0 it denies all content creation as if it was a duplicate.