Try our conversational search powered by Generative AI!

JsonSerialization fails for SEOInformation

Vote:
 

Hi,

I get the following error in my log when Episerver Find tries to serialize ProductContent to Json. It works fine for NodeContent and CatalogContent, but for EntryContent it constantly fails via the "new" Event indexing. If I run the Episerver Find Content Indexing Job everything works fine. When I run the default serializer in EPiServer.Find.Json.Serializer I the stack trace points out SEOInformation[0] "Parent" as the issue.

I have the nuget packages Episerver.Commerce.FindSearchProvider and Episerver.Find.Commerce installed. The configuration files are setup as explained in the documentation.

Is there anyone who has experienced this previously and have a solution to the issue?

2016-03-03 14:22:58,323 [17] ERROR EPiServer.Find.Cms.ContentEventIndexer: An exception occurred while indexing (IContent). Exception has been thrown by the target of an invocation..System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentNullException: The provided content link does not have a value.Parameter name: contentLink   at EPiServer.Core.DefaultContentLoader.Get[T](ContentReference contentLink, LoaderOptions loaderOptions)   at EPiServer.Web.Routing.Segments.NodeSegment.GetVirtualPathSegment(RequestContext requestContext, RouteValueDictionary values)   at EPiServer.Web.Routing.Segments.NodeSegment.GetVirtualPathSegment(RequestContext requestContext, RouteValueDictionary values, HashSet`1 usedValues)   at EPiServer.Web.Routing.ContentRoute.AddVirtualPathFromSegments(StringBuilder virtualPath, RequestContext requestContext, RouteValueDictionary values, HashSet`1 usedValues, Int32 lastNonDefaultIndex)   at EPiServer.Web.Routing.ContentRoute.GetVirtualPath(RequestContext requestContext, RouteValueDictionary values)   at EPiServer.Web.Routing.DefaultUrlResolver.GetUrlFromRoute(ContentReference contentReference, String language, RouteValueDictionary routeValues, RequestContext requestContext)   at EPiServer.Web.Routing.DefaultUrlResolver.GetVirtualPathInternal(ContentReference contentLink, String language, VirtualPathArguments arguments)   at EPiServer.Web.Routing.UrlResolver.GetUrl(ContentReference contentLink, String language)   at EPiServer.Find.Commerce.CommerceUnifiedSearchSetUp.GetContentUrl(ContentReference contentLink)   --- End of inner exception stack trace ---   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)   at System.Delegate.DynamicInvokeImpl(Object[] args)   at EPiServer.Find.UnifiedSearch.IndexProjection.GetUrl(Object o)   at EPiServer.Find.DelegateValueProvider`2.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.BulkActionConverter.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)   at EPiServer.Find.Api.BulkCommand.Execute()   at EPiServer.Find.Cms.ContentIndexer.IndexWithRetry(IContent[] contents, Int32 maxRetries)   at EPiServer.Find.Cms.ContentIndexer.Index(IEnumerable`1 content, IndexOptions options)   at EPiServer.Find.Cms.ContentEventIndexer.IndexPageQueue()System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentNullException: The provided content link does not have a value.Parameter name: contentLink   at EPiServer.Core.DefaultContentLoader.Get[T](ContentReference contentLink, LoaderOptions loaderOptions)   at EPiServer.Web.Routing.Segments.NodeSegment.GetVirtualPathSegment(RequestContext requestContext, RouteValueDictionary values)   at EPiServer.Web.Routing.Segments.NodeSegment.GetVirtualPathSegment(RequestContext requestContext, RouteValueDictionary values, HashSet`1 usedValues)   at EPiServer.Web.Routing.ContentRoute.AddVirtualPathFromSegments(StringBuilder virtualPath, RequestContext requestContext, RouteValueDictionary values, HashSet`1 usedValues, Int32 lastNonDefaultIndex)   at EPiServer.Web.Routing.ContentRoute.GetVirtualPath(RequestContext requestContext, RouteValueDictionary values)   at EPiServer.Web.Routing.DefaultUrlResolver.GetUrlFromRoute(ContentReference contentReference, String language, RouteValueDictionary routeValues, RequestContext requestContext)   at EPiServer.Web.Routing.DefaultUrlResolver.GetVirtualPathInternal(ContentReference contentLink, String language, VirtualPathArguments arguments)   at EPiServer.Web.Routing.UrlResolver.GetUrl(ContentReference contentLink, String language)   at EPiServer.Find.Commerce.CommerceUnifiedSearchSetUp.GetContentUrl(ContentReference contentLink)   --- End of inner exception stack trace ---   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)   at System.Delegate.DynamicInvokeImpl(Object[] args)   at EPiServer.Find.UnifiedSearch.IndexProjection.GetUrl(Object o)   at EPiServer.Find.DelegateValueProvider`2.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.BulkActionConverter.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)   at EPiServer.Find.Api.BulkCommand.Execute()   at EPiServer.Find.Cms.ContentIndexer.IndexWithRetry(IContent[] contents, Int32 maxRetries)   at EPiServer.Find.Cms.ContentIndexer.Index(IEnumerable`1 content, IndexOptions options)   at EPiServer.Find.Cms.ContentEventIndexer.IndexPageQueue()

#145421
Mar 03, 2016 14:32
Vote:
 

Here is the error I get from when manually trying to serialize the content:

{"Self referencing loop detected for property 'Parent' with type 'EPiServer.Core.PropertyDataCollection'. Path 'SeoInformation.Property[0]'. The loop was detected in the member Parent in type EPiServer.Core.PropertyLongString of Castle.Proxies.Perfion100_ItemProxy. To correct this you can exclude one of the properties (or otherwise mapped fields) that are causing the loop by modifying the Client class' conventions. You may also modify the serializer to ignore self references. If you require the fields causing the loop to be serialized you may annotate the one of the classes in the loop with [JsonObject(IsReference = true)] or modify the JsonContract for one of the types to use IsReference = true which also can be done by modifying the Client class' conventions."}

StackTrace:

at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.CheckForCircularReference(JsonWriter writer, Object value, JsonProperty property, JsonContract contract, JsonContainerContract containerContract, JsonProperty containerProperty)
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.SerializeList(JsonWriter writer, IEnumerable values, JsonArrayContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
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 Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType)
at EPiServer.Find.Json.Serializer.SerializeToTextWriter(JsonSerializer serializer, Object value, TextWriter textWriter)

#145423
Mar 03, 2016 14:37
Vote:
 

A contains B which contain A?

Looks like a circular reference is messing up serialization?

#145430
Mar 03, 2016 15:38
Vote:
 

Yeah, that seems to be the issue indeed. The question is why this is happening since I'm not using any custom code but trying to index a default ProductContent.

I found a way around this just now but this solution is based on not indexing the variations attached to the product by using a custom implementation:

protected override void ApplyProductContentConventions(TypeConventionBuilder<ProductContent> conventionBuilder)
{
base.ApplyProductContentConventions(conventionBuilder);

conventionBuilder.ExcludeField(x => x.Variations());
}

#145431
Mar 03, 2016 15:44
Vote:
 

New insight to this issue, the error only occurs when using the Commerce Routing as suggested by the documentation:

[ModuleDependency(typeof(global::EPiServer.Commerce.Initialization.InitializationModule))]
public class RegisterRoutingModuleSample : IInitializableModule
{
public void Initialize(InitializationEngine context)
{
MapRoutes(RouteTable.Routes);
}

private static void MapRoutes(RouteCollection routes)
{
CatalogRouteHelper.MapDefaultHierarchialRouter(routes, true);
}

public void Uninitialize(InitializationEngine context) { /*uninitialize*/}

public void Preload(string[] parameters) { }
}

Does anyone know of a work around for this or does this look lika support ticket?

#145498
Mar 04, 2016 15:24
Vote:
 

Support ticket I guess... 

#145499
Mar 04, 2016 15:30
Vote:
 

I know this is old, but was there ever a solution found for this issue? I'm facing the same exact issue and noticed that it affects my catalog search in the Commerce/Catalog as well.

#175843
Mar 03, 2017 21:55
Vote:
 

The first issue An exception occurred while indexing (IContent). Exception has been thrown by the target of an invocation..System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentNullException: The provided content link does not have a value.Parameter name: contentLink can be caused by the lack of wildcard mapping, or custom registration of hierarchical routing, as mentioned here http://vimvq1987.com/2017/02/find-indexing-job-hierarchicalcatalogpartialrouter-note/

The second issue "Self referencing loop detected for property 'Parent' with type 'EPiServer.Core.PropertyDataCollection'. Path 'SeoInformation.Property[0]'" is caused by the circle reference - so the only way to fix is to look into the catalog content and exclude that kind of reference from indexing.

#175851
Mar 04, 2017 9:32
Vote:
 

Thanks Quan! The custom hierachical routing was the issue.

#175939
Mar 06, 2017 22:19
* 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.