Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Markus Rytterkull 36 posts 207 karma points
    Sep 18, 2024 @ 06:58
    Markus Rytterkull
    0

    Indexing error after upgrade 9 -> 13: Could not parse rich text editor value - JsonSerializationException

    Hi umbracans,

    I am stuck in an upgrade...

    We are getting lots of errors (~800 per indexing on a 1500 page website) after upgrading from 9 to latest 13: "Newtonsoft.Json.JsonSerializationException: Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'Umbraco.Cms.Core.RichTextEditorValue' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly." (full error with callstack below)

    After checking the code in RichTextPropertyEditorHelper and running some simple tests I guess that this occurs when the helper above expects a json-object but just receives a empty array "[]". (Got the same exception in this dotnetfiddle: https://dotnetfiddle.net/xTeM0B)

    I wonder if this error is from some fields have not been converted in the upgrade or that umbraco is mistaking a field for the wrong type, and therefore doing the wrong type conversion.

    This leads me to two question:

    1. How can I find out which fields are causing these errors?
    2. How can this be fixed? Thinking about running a script to update faulty rows in umbracoPropertyData if I can find out which rows are wrong.

    Have tried

    • republishing some nodes to see if this might re-save faulty fields, but get the exact same amount of indexing errors afterwards.

    • searched in umbracoPropertyData to find rows that might be faulty, but have not narrowed down the search yet...

    Grateful for any suggestions, am out of ideas right now.

    Cheers! / Markus

    ------------------ Full exception message Newtonsoft.Json.JsonSerializationException: Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'Umbraco.Cms.Core.RichTextEditorValue' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly. To fix this error either change the JSON to a JSON object (e.g. {"name":"value"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List

    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)

    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)

    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)

    at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)

    at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)

    at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)

    at Umbraco.Cms.Core.PropertyEditors.RichTextPropertyEditorHelper.TryParseRichTextEditorValue(Object value, IJsonSerializer jsonSerializer, ILogger logger, RichTextEditorValue& richTextEditorValue)

    -------------------------------- Search sql

    SELECT distinct textvalue

    FROM cmsPropertyType ct inner join umbracoPropertyData cd on cd.propertyTypeId = ct.id

    WHERE -- all datatypes of richtext-type or nested datatypeid in (1167,1168 ,1245 ,1274,1276,1333,1369,1371,1376,1382,2666,3812,3816,4301,4847, -87, 1161, 1282)

    and textvalue LIKE '%![!]%' ESCAPE '!'

  • Markus Rytterkull 36 posts 207 karma points
    Sep 23, 2024 @ 08:06
    Markus Rytterkull
    100

    How I found out why indexing is producing so many errors:

    • Created a new Index, DebugIndex, that inherited UmbracoContentIndex and a DebugIndexPopulator, and plugged this in startup.cs

    • Could then debug locally and see why it failed.

    Turned out we had a lot of fields that looked like this: "[Missing translation]" , that where mistaken for being json-data.

    Ran a query to update this in database, followed by a Rebuild database cache and memory cache, and then indexing did not produce any more errors :-)

    ----------------- update query

    update umbracoPropertyData set textValue = Replace(textValue, '[Missing translation]', 'Missing translation') where textValue like '%![Missing translation!]%' escape '!'

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies