Skip to content

PlaceholderFeatureConverter crashes when deserializing a page with personalization applied #59

@richardhauer

Description

@richardhauer

What happened?

Problem as described. Any page with personalization will crash the web app.

Reproduction Steps

  1. Apply personalisation to a page in Pages Editor
  2. Try to open page

The following stack track is produced:

      Unhandled exception rendering component: The JSON value could not be converted to Sitecore.AspNetCore.SDK.LayoutService.Client.Response.Model.Placeholder. Path: $.sitecore.route.placeholders.headless-main | LineNumber: 0 | BytePositionInLine: 5473.
      System.Text.Json.JsonException: The JSON value could not be converted to Sitecore.AspNetCore.SDK.LayoutService.Client.Response.Model.Placeholder. Path: $.sitecore.route.placeholders.headless-main | LineNumber: 0 | BytePositionInLine: 5473.
       ---> System.InvalidOperationException: Cannot get the value of a token type 'EndObject' as a string.
         at System.Text.Json.ThrowHelper.ThrowInvalidOperationException_ExpectedString(JsonTokenType tokenType)
         at System.Text.Json.Utf8JsonReader.GetString()
         at Sitecore.AspNetCore.SDK.LayoutService.Client.Serialization.Converter.PlaceholderFeatureConverter.GetPlaceholderFeature(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options)
         at Sitecore.AspNetCore.SDK.LayoutService.Client.Serialization.Converter.PlaceholderFeatureConverter.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options)
         at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue)
         at System.Text.Json.Serialization.JsonDictionaryConverter`3.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, TDictionary& value)
         at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue)
         at System.Text.Json.Serialization.Metadata.JsonPropertyInfo`1.ReadJsonAndSetMember(Object obj, ReadStack& state, Utf8JsonReader& reader)
         at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
         at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue)
         at System.Text.Json.Serialization.Metadata.JsonPropertyInfo`1.ReadJsonAndSetMember(Object obj, ReadStack& state, Utf8JsonReader& reader)
         at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
         at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue)
         at System.Text.Json.Serialization.Metadata.JsonPropertyInfo`1.ReadJsonAndSetMember(Object obj, ReadStack& state, Utf8JsonReader& reader)
         at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
         at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue)
         at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, T& value, JsonSerializerOptions options, ReadStack& state)
         --- End of inner exception stack trace ---
         at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, Utf8JsonReader& reader, Exception ex)
         at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, T& value, JsonSerializerOptions options, ReadStack& state)
         at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.Deserialize(Utf8JsonReader& reader, ReadStack& state)
         at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 utf8Json, JsonTypeInfo`1 jsonTypeInfo, Nullable`1 actualByteCount)
         at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 json, JsonTypeInfo`1 jsonTypeInfo)
         at System.Text.Json.JsonSerializer.Deserialize[TValue](String json, JsonSerializerOptions options)
         at Sitecore.AspNetCore.SDK.LayoutService.Client.Serialization.JsonLayoutServiceSerializer.Deserialize(String data)
         at Sitecore.AspNetCore.SDK.LayoutService.Client.Request.Handlers.GraphQL.GraphQLLayoutServiceHandler.Request(SitecoreLayoutRequest request, String handlerName)
         at Sitecore.AspNetCore.SDK.LayoutService.Client.DefaultLayoutClient.Request(SitecoreLayoutRequest request, String handlerName)

Relevant log output

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions