umbraco / Umbraco-CMS

Umbraco is a free and open source .NET content management system helping you deliver delightful digital experiences.
https://umbraco.com
Other
4.49k stars 2.69k forks source link

Exception is thrown when trying to add property with identical alias to composition #14099

Closed PeterKvayt closed 1 year ago

PeterKvayt commented 1 year ago

Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)

11.3.0

Bug summary

When I have 2 compositions, which are already used in one doc type and I add property to composition with the same property alias which already exists in other used composition, I got an exception with stack trace.

It would be great to get nice error page with explanation why we can't save composition with this property.

Specifics

I did not test this case in other versions, but Im quite sure that this will reproduced in 10.x version

image

at System.Linq.ThrowHelper.ThrowNoMatchException() at System.Linq.Enumerable.Single[TSource](IEnumerable1 source, Func2 predicate) at Umbraco.Cms.Web.BackOffice.Controllers.ContentTypeControllerBase1.AddCompositionValidationErrors[TContentTypeSave,TPropertyType](TContentTypeSave contentTypeSave, IEnumerable1 duplicatePropertyTypeAliases, IEnumerable1 invalidPropertyGroupAliases) at Umbraco.Cms.Web.BackOffice.Controllers.ContentTypeControllerBase1.CreateCompositionValidationExceptionIfInvalid[TContentTypeSave,TPropertyType,TContentTypeDisplay](TContentTypeSave contentTypeSave, TContentType composition) at Umbraco.Cms.Web.BackOffice.Controllers.ContentTypeControllerBase1.PerformPostSave[TContentTypeDisplay,TContentTypeSave,TPropertyType](TContentTypeSave contentTypeSave, Func2 getContentType, Action1 saveContentType, Action1 beforeCreateNew) at Umbraco.Cms.Web.BackOffice.Controllers.ContentTypeController.PostSave(DocumentTypeSave contentTypeSave) at lambda_method3740(Closure, Object, Object[]) at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncObjectResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync() at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync() --- End of stack trace from previous location --- 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)

Steps to reproduce

  1. Create composition "Test" doc type with group name "Foo" with propetry "Bar" with editor Umbraco.TrueFalse
  2. Create usual doc type "Doc" with template
  3. Add composition "Test" to "Doc"
  4. Create copy of "Test" composition, then you will get "Test (copy)"
  5. Remove property "Bar" from "Test (copy)"
  6. Add composition "Test (cope)" to "Doc"
  7. Add property "Bar" (exactly the same as in the first step) to "Test (copy)"
  8. Try to save changes

Expected result / actual result

Expected result: there is an error message that we create property with the same alias name with already exists in used doc type.

Actual result: there is an exception while trying to save changes.

github-actions[bot] commented 1 year ago

Hi there @PeterKvayt!

Firstly, a big thank you for raising this issue. Every piece of feedback we receive helps us to make Umbraco better.

We really appreciate your patience while we wait for our team to have a look at this but we wanted to let you know that we see this and share with you the plan for what comes next.

We wish we could work with everyone directly and assess your issue immediately but we're in the fortunate position of having lots of contributions to work with and only a few humans who are able to do it. We are making progress though and in the meantime, we will keep you in the loop and let you know when we have any questions.

Thanks, from your friendly Umbraco GitHub bot :robot: :slightly_smiling_face:

elit0451 commented 1 year ago

Hi @PeterKvayt 👋 Thanks for reaching out and for the detailed steps for reproducing your issue 💪 When I tried your scenario on a fresh Umbraco 11.3 installation, I was getting validation errors that point to the problem pretty clearly, as you can see in the video below. Wasn't it the same for you or perhaps I am missing something?

https://user-images.githubusercontent.com/21998037/232459861-3fc4a541-d40c-4eae-b029-f2347cec818b.mp4

PeterKvayt commented 1 year ago

Hi @elit0451! Yes, you are right, it's works fine, may be it was my fault. I will investigate it more deeply later. Anyway thanks!