Try our conversational search powered by Generative AI!

Indexing job, many JsonSerializationException (because of NullReferenceException) on optional property

Vote:
 

We're in the process of upgrading an CMS 11 app to CMS 12.

We upgraded the CMS and Find.Cms packages recently (to 12.22.5 and 15.2.0 respectively) and the index job started to fail every time.

There are a lot of JsonSerializationException (because of NullReferenceException) errors when getting some values, mostly the same subclass optional string property.

Why are Find throwing errors on properties that is allowed to be null?

Below is one log instance:

2023-09-06 11:19:14.3159|ERROR|EPiServer.Framework.FrameworkInitialization|EPiServer Find serialization failed.
Newtonsoft.Json.JsonSerializationException: Error getting value from 'MetaTitle' on 'SomeProjectNameSpace.SiteBasePageData_DynamicProxy'.
 ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at SomeProjectNameSpace.SiteBasePageData_DynamicProxy.get_MetaTitle()
   at Newtonsoft.Json.Serialization.ExpressionValueProvider.GetValue(Object target)
   --- End of inner exception stack trace ---
   at Newtonsoft.Json.Serialization.ExpressionValueProvider.GetValue(Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.CalculatePropertyValues(JsonWriter writer, Object value, JsonContainerContract contract, JsonProperty member, JsonProperty property, JsonContract& memberContract, Object& memberValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)|Newtonsoft.Json.JsonSerializationException: Error getting value from 'MetaTitle' on 'SomeProjectNameSpace.SiteBasePageData_DynamicProxy'.
 ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at SomeProjectNameSpace.SiteBasePageData_DynamicProxy.get_MetaTitle()
   at Newtonsoft.Json.Serialization.ExpressionValueProvider.GetValue(Object target)
   --- End of inner exception stack trace ---
   at Newtonsoft.Json.Serialization.ExpressionValueProvider.GetValue(Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.CalculatePropertyValues(JsonWriter writer, Object value, JsonContainerContract contract, JsonProperty member, JsonProperty property, JsonContract& memberContract, Object& memberValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)
   at EPiServer.Find.Api.ActionConverterBase.WriteJson(JsonWriter writer, Object value, JsonSerializer serializer)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeConvertable(JsonWriter writer, JsonConverter converter, Object value, JsonContract contract, JsonContainerContract collectionContract, JsonProperty containerProperty)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)
   at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType)
   at EPiServer.Find.Json.Serializer.SerializeToTextWriter(JsonSerializer serializer, Object value, TextWriter textWriter)
   at EPiServer.Find.Json.Serializer.SerializeObjectsToJsonRequest(JsonSerializer serializer, IJsonRequest jsonRequest, IEnumerable values)
2023-09-06 11:19:14.3159|ERROR|EPiServer.Framework.FrameworkInitialization|EPiServer Find serialization failed.
Newtonsoft.Json.JsonSerializationException: Error getting value from 'MetaTitle' on 'SomeProjectNameSpace.SiteBasePageData_DynamicProxy'.
 ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at SomeProjectNameSpace.SiteBasePageData_DynamicProxy.get_MetaTitle()
   at Newtonsoft.Json.Serialization.ExpressionValueProvider.GetValue(Object target)
   --- End of inner exception stack trace ---
   at Newtonsoft.Json.Serialization.ExpressionValueProvider.GetValue(Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.CalculatePropertyValues(JsonWriter writer, Object value, JsonContainerContract contract, JsonProperty member, JsonProperty property, JsonContract& memberContract, Object& memberValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)|Newtonsoft.Json.JsonSerializationException: Error getting value from 'MetaTitle' on 'SomeProjectNameSpace.SiteBasePageData_DynamicProxy'.
 ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at SomeProjectNameSpace.SiteBasePageData_DynamicProxy.get_MetaTitle()
   at Newtonsoft.Json.Serialization.ExpressionValueProvider.GetValue(Object target)
   --- End of inner exception stack trace ---
   at Newtonsoft.Json.Serialization.ExpressionValueProvider.GetValue(Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.CalculatePropertyValues(JsonWriter writer, Object value, JsonContainerContract contract, JsonProperty member, JsonProperty property, JsonContract& memberContract, Object& memberValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)
   at EPiServer.Find.Api.ActionConverterBase.WriteJson(JsonWriter writer, Object value, JsonSerializer serializer)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeConvertable(JsonWriter writer, JsonConverter converter, Object value, JsonContract contract, JsonContainerContract collectionContract, JsonProperty containerProperty)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)
   at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType)
   at EPiServer.Find.Json.Serializer.SerializeToTextWriter(JsonSerializer serializer, Object value, TextWriter textWriter)
   at EPiServer.Find.Json.Serializer.SerializeObjectsToJsonRequest(JsonSerializer serializer, IJsonRequest jsonRequest, IEnumerable values)
2023-09-06 11:19:14.3159|ERROR|EPiServer.Framework.FrameworkInitialization|EPiServer Find serialization failed.
Newtonsoft.Json.JsonSerializationException: Error getting value from 'MetaTitle' on 'SomeProjectNameSpace.SiteBasePageData_DynamicProxy'.
 ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at SomeProjectNameSpace.SiteBasePageData_DynamicProxy.get_MetaTitle()
   at Newtonsoft.Json.Serialization.ExpressionValueProvider.GetValue(Object target)
   --- End of inner exception stack trace ---
   at Newtonsoft.Json.Serialization.ExpressionValueProvider.GetValue(Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.CalculatePropertyValues(JsonWriter writer, Object value, JsonContainerContract contract, JsonProperty member, JsonProperty property, JsonContract& memberContract, Object& memberValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)
   at EPiServer.Find.Api.ActionConverterBase.WriteJson(JsonWriter writer, Object value, JsonSerializer serializer)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeConvertable(JsonWriter writer, JsonConverter converter, Object value, JsonContract contract, JsonContainerContract collectionContract, JsonProperty containerProperty)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)|Newtonsoft.Json.JsonSerializationException: Error getting value from 'MetaTitle' on 'SomeProjectNameSpace.SiteBasePageData_DynamicProxy'.
 ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at SomeProjectNameSpace.SiteBasePageData_DynamicProxy.get_MetaTitle()
   at Newtonsoft.Json.Serialization.ExpressionValueProvider.GetValue(Object target)
   --- End of inner exception stack trace ---
   at Newtonsoft.Json.Serialization.ExpressionValueProvider.GetValue(Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.CalculatePropertyValues(JsonWriter writer, Object value, JsonContainerContract contract, JsonProperty member, JsonProperty property, JsonContract& memberContract, Object& memberValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)
   at EPiServer.Find.Api.ActionConverterBase.WriteJson(JsonWriter writer, Object value, JsonSerializer serializer)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeConvertable(JsonWriter writer, JsonConverter converter, Object value, JsonContract contract, JsonContainerContract collectionContract, JsonProperty containerProperty)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)
   at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType)
   at EPiServer.Find.Json.Serializer.SerializeToTextWriter(JsonSerializer serializer, Object value, TextWriter textWriter)
   at EPiServer.Find.Json.Serializer.SerializeObjectsToJsonRequest(JsonSerializer serializer, IJsonRequest jsonRequest, IEnumerable values)
2023-09-06 11:19:14.4851|WARN|EPiServer.Find.Cms.ContentIndexer|Indexing failed (1 indexing errors), attempt 3 out of 3: SerializationException: failed to serialize item #0
#308057
Edited, Sep 06, 2023 9:57
Vote:
 

What is your definition of MetaTitle in code? 

#308058
Sep 06, 2023 10:19
Vote:
 
public abstract class SiteBasePageData : PageData
{
    [MaxLength(60)]
    [CultureSpecific]
    [Display(Order = 1, GroupName = TabNames.Meta)]
    public virtual string MetaTitle { get; set; }
}
#308059
Sep 06, 2023 10:24
Vote:
 

It could very well be connected with the other issue I'm having:

Find Indexing job fails early but seemingly keeps on running in b (optimizely.com)

And this occurs in the background threads...

#308063
Sep 06, 2023 13:30
* 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.