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

Switching property from Block Grid to Block List cause save errors #14433

Closed bjarnef closed 1 year ago

bjarnef commented 1 year ago

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

11.4.0

Bug summary

On a block element I had property "items" using Block Grid, where I added some items.

image

Later I changed the property to a Block List instead and deleted the Block Grid datatype instance.

Now when trying to add items to the property using Block List and save content, it fails.

chrome_4yquWg2oLc

If I renamed the property alias (using Block List) to something else than items it does save. It seems the property with alias items somehow still reference the original Block Grid datatype, which was deleted.

Specifics

No response

Steps to reproduce

Expected result / actual result

No response


_This item has been added to our backlog AB#31584_

github-actions[bot] commented 1 year ago

Hi there @bjarnef!

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:

bjarnef commented 1 year ago

I also noticed when renaming the "nested" property alias using Block List, the existing items dissapears from UI.

I think it should be allowed to renamed property alias (as with other property editors) without data-loss. At least when not changing property editor.

kjac commented 1 year ago

Hi @bjarnef,

Thank you for reporting 💪 unfortunately I'm having a hard time reproducing the issue on V12.

Here's a screencast of me trying:

14433.webm

Does this test mimic the issue scenario you're experiencing on V11?

bjarnef commented 1 year ago

Hi @kjac

Maybe I should elaborate that I didn't replace Block Grid to Block List directly on a property on the content type, but on an element type used in a Block Grid on the content type 😁

image

So the switch / replacement on Block Grid to Block List happened on the block element inserted on the Block Grid on the content node 😎

Think "nested" Block Grid / Block List 😄

kjac commented 1 year ago

Hi again 😄

...I still can't reproduce it 🙈

14433-2.webm

kjac commented 1 year ago

Hi @bjarnef,

We haven't heard from you in a while on this one, so I'm closing it now. If the problem indeed still persists, please feel free to reopen the issue with additional steps to reproduce.

bjarnef commented 1 year ago

Hi @kjac

I have tested with latest changes in contrib branch, but was still able to reproduce the issue when replacing "Items" property using "BG - Assets" with "BL - Assets", delete "BG - Assets" datatype and go back to content section where the "Items" are empty, but hitting save & publish throw an exception, because it somehow reference the "BG - Assets" datatype.

https://github.com/umbraco/Umbraco-CMS/assets/2919859/7f1ab602-4684-4b55-8062-4a4bd2206d5e

Exception Details

System.InvalidOperationException, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e: No data type found by id 1180

Stacktrace

at Umbraco.Cms.Core.Services.PropertyValidationService.ValidatePropertyValue(IPropertyType propertyType, Object postedValue) in C:\VSProjects\umbraco-cms\src\Umbraco.Core\Services\PropertyValidationService.cs:line 41
   at Umbraco.Cms.Core.PropertyEditors.ComplexEditorValidator.GetNestedValidationResults(IEnumerable`1 elements)+MoveNext() in C:\VSProjects\umbraco-cms\src\Umbraco.Infrastructure\PropertyEditors\ComplexEditorValidator.cs:line 66
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at Umbraco.Cms.Core.PropertyEditors.ComplexEditorValidator.Validate(Object value, String valueType, Object dataTypeConfiguration) in C:\VSProjects\umbraco-cms\src\Umbraco.Infrastructure\PropertyEditors\ComplexEditorValidator.cs:line 33
   at Umbraco.Cms.Core.PropertyEditors.DataValueEditor.<>c__DisplayClass29_0.<Validate>b__0(IValueValidator v) in C:\VSProjects\umbraco-cms\src\Umbraco.Core\PropertyEditors\DataValueEditor.cs:line 123
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.ToList()
   at Umbraco.Cms.Core.PropertyEditors.DataValueEditor.Validate(Object value, Boolean required, String format) in C:\VSProjects\umbraco-cms\src\Umbraco.Core\PropertyEditors\DataValueEditor.cs:line 123
   at Umbraco.Cms.Core.Services.PropertyValidationService.ValidatePropertyValue(IDataEditor editor, IDataType dataType, Object postedValue, Boolean isRequired, String validationRegExp, String isRequiredMessage, String validationRegExpMessage)+MoveNext() in C:\VSProjects\umbraco-cms\src\Umbraco.Core\Services\PropertyValidationService.cs:line 73
   at Umbraco.Cms.Web.BackOffice.Filters.ContentModelValidator`3.ValidatePropertyValue(TModelSave model, TModelWithProperties modelWithProperties, IDataEditor editor, ContentPropertyDto property, Object postedValue, ModelStateDictionary modelState) in C:\VSProjects\umbraco-cms\src\Umbraco.Web.BackOffice\Filters\ContentModelValidator.cs:line 193
   at Umbraco.Cms.Web.BackOffice.Filters.ContentModelValidator`3.ValidatePropertiesData(TModelSave model, TModelWithProperties modelWithProperties, ContentPropertyCollectionDto dto, ModelStateDictionary modelState) in C:\VSProjects\umbraco-cms\src\Umbraco.Web.BackOffice\Filters\ContentModelValidator.cs:line 158
   at Umbraco.Cms.Web.BackOffice.Filters.ContentSaveValidationAttribute.ContentSaveValidationFilter.OnActionExecutingAsync(ActionExecutingContext context) in C:\VSProjects\umbraco-cms\src\Umbraco.Web.BackOffice\Filters\ContentSaveValidationAttribute.cs:line 103
   at Umbraco.Cms.Web.BackOffice.Filters.ContentSaveValidationAttribute.ContentSaveValidationFilter.OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next) in C:\VSProjects\umbraco-cms\src\Umbraco.Web.BackOffice\Filters\ContentSaveValidationAttribute.cs:line 57
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>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.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
bjarnef commented 1 year ago

Switching the "items" property to textarea I get the existing stored data:

{"layout":{"Umbraco.BlockGrid":[{"contentUdi":"umb://element/c967d3a5395e4e8490f535fe6167df0d","areas":[],"columnSpan":12,"rowSpan":1},{"contentUdi":"umb://element/752978f7b2c446b5b7a77e9cfd927b3c","areas":[],"columnSpan":12,"rowSpan":1},{"contentUdi":"umb://element/1ec7b3bea25f4ec79863dc2c0a642a12","areas":[],"columnSpan":12,"rowSpan":1}]},"contentData":[{"contentTypeKey":"1b415b13-c8a5-4d09-af14-b63a9fc23a04","udi":"umb://element/c967d3a5395e4e8490f535fe6167df0d","title":"Test 1","link":"[{\"name\":\"#\",\"queryString\":\"#\"}]"},{"contentTypeKey":"1b415b13-c8a5-4d09-af14-b63a9fc23a04","udi":"umb://element/752978f7b2c446b5b7a77e9cfd927b3c","title":"Test 2","link":"[{\"name\":\"#\",\"queryString\":\"#\"}]"},{"contentTypeKey":"1b415b13-c8a5-4d09-af14-b63a9fc23a04","udi":"umb://element/1ec7b3bea25f4ec79863dc2c0a642a12","title":"Test 3","link":"[{\"name\":\"#\",\"queryString\":\"#\"}]"}],"settingsData":[]}

image

even when changed property editor to textarea the save & publish fail with the exception mentioned and strange enough also when clearing the textarea.

https://github.com/umbraco/Umbraco-CMS/assets/2919859/b3382d78-6094-4311-a17a-358d4763f5d3

kjac commented 1 year ago

Thank you for the videos @bjarnef 😄 I will make sure we find time to dig into this in an upcoming sprint 👍

bjarnef commented 1 year ago

A workaround is to delete the property and add a new property with a different alias.

I also tried creating a new "BG - Asssets" (Block Grid) datatype instance (with a different id). When I went to content section again the items are shown again, because of the Block Grid data structure, but save & publish also seemed to work.