PropertyList serialization error after upgrade to CMS 12

Vote:
 

Hi

We have a bunch of propertylists in our project, all of which started throwing serialization errors post upgrade to CMS 12. Here's a detailed exception : 

Unexpected error when updating property groupsForNewsAudienceTargeting
Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: [. Path '', line 1, position 1.
   at Newtonsoft.Json.JsonTextReader.ReadStringValue(ReadType readType)
   at Newtonsoft.Json.JsonTextReader.ReadAsString()
   at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at EPiServer.Cms.Shell.UI.Rest.ContentChangeManager.Deserialize(String value, Type type)
   at EPiServer.Cms.Shell.UI.Rest.ContentChangeManager.UpdateProperties(IDictionary`2 properties, IContent content)
08/05/2022 12:22:49 An exception occurred while converting JSON property
Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: [. Path '', line 1, position 1.
   at Newtonsoft.Json.JsonTextReader.ReadStringValue(ReadType readType)
   at Newtonsoft.Json.JsonTextReader.ReadAsString()
   at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)

I compared our logic against Foundation for .net6 and its pretty much the same.

After much trial and error, when i deleted the old content type that had the propertylist on it in DB, and let the code recreate it at next launch, was I able to get these to work again. However, considering this is an existing live site going under the upgrade, deleting content types causes us to lose all content created for that type and will have to recreate it once new content type is in. 

I don't know if this issue is introduced by the .net core DB upgrade scripts or the internal library upgrades. But this is definitely a roadblock fo us to proceed.

Please advice on how to resolve this without losing content.

P.S. : On a side note, we ran into a similar serialization error with the new Episerver.Social packages and after opening a support ticket and escalations, that was identified as a bug in Episerver.Social and fixed. Could we maybe have a similar issue here in the Core packages?

Update :

Seeing this new exception today : 

08/09/2022 12:55:30 Detected change of type on property GroupsForNewsAudienceTargeting on AdSettings. Converting existing content of type EPiServer.Core.DefaultPropertyJson to new backing type NMIC02_DC.Features.Settings.AdGroupProperty is not possible without loss of data. No change is commited.

All I did was follow the recommendation in this thread : CollectionEditor not displaying items | Optimizely Developer Comm

So added this to my propertyList : 

[Display(Name = "AD groups for news audience targeting", Order = 10)]
        [EditorDescriptor(EditorDescriptorType = typeof(CollectionEditorDescriptor<AdGroup>))]
        [ClientEditor(ClientEditingClass = "nmic02/ADSettingsCollectionEditor")]
        public virtual IEnumerable<AdGroup> GroupsForNewsAudienceTargeting { get; set; }

 [PropertyDefinitionTypePlugIn]
    public class AdGroupProperty : PropertyList<AdGroup>
    {
        private Injected<ObjectSerializerFactory> _objectSerializerFactory;
        protected override AdGroup ParseItem(string value)
        {
            var objectSerializer = _objectSerializerFactory.Service.GetSerializer("application/json");
            return objectSerializer.Deserialize<AdGroup>(value);
        }
    }

    [PropertyDefinitionTypePlugIn]
    public class AdGroupValueProperty : PropertyList<AdGroupValue>
    {
        private Injected<ObjectSerializerFactory> _objectSerializerFactory;
        protected override AdGroupValue ParseItem(string value)
        {
            var objectSerializer = _objectSerializerFactory.Service.GetSerializer("application/json");
            return objectSerializer.Deserialize<AdGroupValue>(value);
        }
    }

Regards

Ritu

#285240
Edited, Aug 09, 2022 16:13
Vote:
 

Did you look at what was stored in the DB for the propertylist vs what it looks like we fresh data?

#285241
Aug 09, 2022 16:30
Vote:
 

Hi Surjit

Yes I did and its the same before and after. See below. The top one is created new from CMS 12 and the below was what was there previously for another type. No difference as such.

#285243
Aug 09, 2022 16:47
Vote:
 

Ritu, what version did you upgrade FROM?

#285344
Aug 11, 2022 1:47
Vote:
 

Hey Surjit.. we upgraded from CMS11.

And we found the issue. We created a brand new solution for CMS 12 and not sure entirely why, but ended up changing the assembly name slightly on the new solution. And that blew up in our face with all these issues, especially with types that didn't have a GUID on them. PropertyDefinition Types were one such example. As soon as I reverted the assembly name to what it was in CMS 11, everything just worked.

So, now we know why guids and assembly names are so relevant in this context.

Thanks again!

#285418
Aug 12, 2022 14:17
Vote:
 

Hey Surjit.. we upgraded from CMS11.

And we found the issue. We created a brand new solution for CMS 12 and not sure entirely why, but ended up changing the assembly name slightly on the new solution. And that blew up in our face with all these issues, especially with types that didn't have a GUID on them. PropertyDefinition Types were one such example. As soon as I reverted the assembly name to what it was in CMS 11, everything just worked.

So, now we know why guids and assembly names are so relevant in this context.

Thanks again!

#285419
Aug 12, 2022 14:17
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.