Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing datatype property editor breaks content type #8976

Closed
callumbwhyte opened this issue Sep 28, 2020 · 3 comments
Closed

Changing datatype property editor breaks content type #8976

callumbwhyte opened this issue Sep 28, 2020 · 3 comments
Labels
status/stale Marked as stale due to inactivity

Comments

@callumbwhyte
Copy link
Contributor

callumbwhyte commented Sep 28, 2020

As of the latest Umbraco 8.7, changing the property editor attached to a datatype breaks any doctypes using it.

Reproduction

  1. Add a property to a Content Type. Here I chose to create a new instance of the Textbox property editor.

Screenshot 2020-09-29 at 00 03 46

  1. Navigate to the Data Type tree, select the data type that was just created.

Screenshot 2020-09-29 at 00 05 09

  1. Change the property editor selected for that Data Type. Save.

Screenshot 2020-09-29 at 00 05 35

In this case, the property editor used to be Umbraco.Textbox but it is now Umbraco.MultiNodeTreePicker.

  1. Navigate back to the Content Type that implements this Data Type. Note the property editor alias shown for the data type is now wrong.

Screenshot 2020-09-29 at 00 05 59

4.1. When loading the preview for some complex editors an error is presented. It looks like the old data type configuration is passed to the new data type, which obviously results in an error.

Here is the error thrown when switching from Nested Content to Block List.

System.ArgumentException: Expected a NestedContentConfiguration instance, but got BlockListConfiguration.
Parameter name: value
   at Umbraco.Web.PropertyEditors.NestedContentPropertyEditor.NestedContentPropertyValueEditor.set_Configuration(Object value) in D:\a\1\s\src\Umbraco.Web\PropertyEditors\NestedContentPropertyEditor.cs:line 92
   at Umbraco.Core.PropertyEditors.DataEditor.GetValueEditor(Object configuration) in D:\a\1\s\src\Umbraco.Core\PropertyEditors\DataEditor.cs:line 117
   at Umbraco.Web.Models.Mapping.ContentPropertyDisplayMapper.Map(Property originalProp, ContentPropertyDisplay dest, MapperContext context) in D:\a\1\s\src\Umbraco.Web\Models\Mapping\ContentPropertyDisplayMapper.cs:line 24
   at Umbraco.Core.Mapping.UmbracoMapper.Map[TTarget](Object source, Type sourceType, MapperContext context) in D:\a\1\s\src\Umbraco.Core\Mapping\UmbracoMapper.cs:line 207
   at Umbraco.Core.Mapping.UmbracoMapper.Map[TSource,TTarget](TSource source, MapperContext context) in D:\a\1\s\src\Umbraco.Core\Mapping\UmbracoMapper.cs:line 190
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at Umbraco.Web.Models.Mapping.TabsAndPropertiesMapper`1.Map(TSource source, MapperContext context) in D:\a\1\s\src\Umbraco.Web\Models\Mapping\TabsAndPropertiesMapper.cs:line 150
   at Umbraco.Web.Models.Mapping.ContentMapDefinition.Map(IContent source, ContentVariantDisplay target, MapperContext context) in D:\a\1\s\src\Umbraco.Web\Models\Mapping\ContentMapDefinition.cs:line 117
   at Umbraco.Core.Mapping.UmbracoMapper.Map[TTarget](Object source, Type sourceType, MapperContext context) in D:\a\1\s\src\Umbraco.Core\Mapping\UmbracoMapper.cs:line 207
   at Umbraco.Web.Models.Mapping.ContentVariantMapper.Map(IContent source, MapperContext context) in D:\a\1\s\src\Umbraco.Web\Models\Mapping\ContentVariantMapper.cs:line 35
   at Umbraco.Web.Models.Mapping.ContentMapDefinition.Map(IContent source, ContentItemDisplay target, MapperContext context) in D:\a\1\s\src\Umbraco.Web\Models\Mapping\ContentMapDefinition.cs:line 102
   at Umbraco.Core.Mapping.UmbracoMapper.Map[TTarget](Object source, Type sourceType, MapperContext context) in D:\a\1\s\src\Umbraco.Core\Mapping\UmbracoMapper.cs:line 207
   at Umbraco.Core.Mapping.UmbracoMapper.Map[TTarget](Object source, MapperContext context) in D:\a\1\s\src\Umbraco.Core\Mapping\UmbracoMapper.cs:line 154
   at Umbraco.Web.Editors.ContentController.MapToDisplay(IContent content) in D:\a\1\s\src\Umbraco.Web\Editors\ContentController.cs:line 2241
   at Umbraco.Web.Editors.ContentController.GetEmpty(IContentType contentType, Int32 parentId) in D:\a\1\s\src\Umbraco.Web\Editors\ContentController.cs:line 381
@nul800sebastiaan
Copy link
Member

Is this new behavior though? I haven't grasped this completely yet, but it's not very surprising that content that you change from a textstring to a NestedContent property can't be deserialized and give errors right? 🙈

But you seem to imply we used to quietly ignore this?

@callumbwhyte
Copy link
Contributor Author

callumbwhyte commented Oct 6, 2020

I made a small error in my previous explanation (now updated) that totally changed the meaning of the issue... 🤦‍♂️

If you change the property editor that a data type implements, any doctypes using that data type still point to the old property editor until you go in and re-pick the data type.

You can see this in the UI (comparing screenshots #1 and #4 above) - changed from Umbraco.Textbox to Umbraco.MultiNodeTreePicker but the doctype editor still shows Umbraco.Textbox.

Some complex editors, like Nested Content and Block List, load a "scaffold" from the API to render the preview. It seems the old data type details and property value converter are being used are used to render the scaffold for the new data type which results in an error.

This error implies the wrong / old data type configuration object is being passed to the scaffold method after changing from Nested Content to Block List:

Expected a NestedContentConfiguration instance, but got BlockListConfiguration

@umbrabot
Copy link

Hiya @callumbwhyte,

Just wanted to let you know that we noticed that this issue got a bit stale and might not be relevant any more.

We will close this issue for now but we're happy to open it up again if you think it's still relevant (for example: it's a feature request that's not yet implemented, or it's a bug that's not yet been fixed).

To open it this issue up again, you can write @umbrabot still relevant in a new comment as the first line. It would be super helpful for us if on the next line you could let us know why you think it's still relevant.

For example:

@umbrabot still relevant
This bug can still be reproduced in version x.y.z

This will reopen the issue in the next few hours.

Thanks, from your friendly Umbraco GitHub bot 🤖 🙂

@umbrabot umbrabot added the status/stale Marked as stale due to inactivity label Jul 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/stale Marked as stale due to inactivity
Projects
None yet
Development

No branches or pull requests

3 participants