Object reference not set to an instance of an object when viewing root catalogue or trying to view products

Vote:
 

Whenever i view the commerce section locally on my website i get this error message followed by another middleware error message when the middleware finishes and calls await _next(context); : 'Object reference not set to an instance of an object.'. None of the middleware code is affecting the request as the middlewares conditions aren't met when navigating to the commerce page the call goes to the await _next(context) line which results in a seperate error with the same basis as below for "System.NullReferenceException: 'Object reference not set to an instance of an object.'". I'm not sure what has caused this I'm unable to view any of the products as it causes this same error locally but when testing on testing and production environments everything works fine. Im assuming that the local commerce database is broken but I'm not sure if theres a way to test or fix the issue?

EPiServer.Framework.Cache.ObjectInstanceCacheExtensions[0]
      Failed to Read cacheKey = 'EPPageData:68:en__CatalogContent'
      System.NullReferenceException: Object reference not set to an instance of an object.
         at EPiServer.Commerce.Catalog.Provider.MetaDataPropertyMapper.AssignMetaFieldValueToProperty(PropertyData property, Object metaFieldValue, MetaDataType metaDataType, String blockPropertyMetaFieldName)
         at EPiServer.Commerce.Catalog.Provider.Construction.CatalogPropertyLoader.AddMetaDataAttributePropertyValues(MetaObjectAccessor accessor, CatalogContentBase content)
         at EPiServer.Commerce.Catalog.Provider.Construction.CatalogPropertyLoader.LoadMetaDataContentProperties(MetaObjectAccessor accessor, CatalogContentBase content)
         at EPiServer.Commerce.Catalog.Provider.Construction.CatalogPropertyLoader.LoadProperties(CatalogEntryRow entryRow, CatalogItemSeoRow seoRow, VariationRow variationRow, EntryContentBase content, MetaObjectAccessor metaObjectAccessor)
         at EPiServer.Commerce.Catalog.Provider.Construction.EntryBuilder.SetEntryContentProperties(EntryContentBase entry, CatalogEntryRow entryRow, String contentLanguage, MetaObject metaObj, IDictionary`2 versionsForUnpublishedContent, IDictionary`2 primaryNodeRelations)
         at EPiServer.Commerce.Catalog.Provider.Construction.EntryBuilder.ConstructEntries(CatalogEntryDto entryDto, IDictionary`2 versionsForUnpublishedContent, IDictionary`2 primaryNodeRelations, String language)
         at EPiServer.Commerce.Catalog.Provider.Construction.EntryBuilder.Create(IList`1 contentLinks, String language)
         at EPiServer.Commerce.Catalog.Provider.CatalogContentLoader.<>c__DisplayClass9_0.<LoadSpecificContentInstances>b__0(ICatalogContentBuilder builder, IList`1 links)
         at EPiServer.Commerce.Catalog.Provider.CatalogContentLoader.ConstructContent(IList`1 contentLinks, Func`3 createContentFunc)
         at EPiServer.Commerce.Catalog.Provider.CatalogContentLoader.LoadSpecificContentInstances(IList`1 contentLinks, String language)
         at EPiServer.Commerce.Catalog.Provider.CatalogContentProvider.<>c__DisplayClass29_0.<LoadContents>b__1(IList`1 refs)
         at EPiServer.Commerce.Catalog.Provider.CatalogContentProvider.BatchLoad(IList`1 contentLinks, Func`2 dbLoader)
         at EPiServer.Commerce.Catalog.Provider.CatalogContentProvider.LoadContents(IList`1 contentReferences, ILanguageSelector selector)
         at EPiServer.Commerce.Catalog.Provider.CatalogContentProvider.LoadContent(ContentReference contentLink, ILanguageSelector languageSelector)
         at EPiServer.Core.ContentProvider.<>c__DisplayClass123_0.<LoadContentFromCacheOrRepository>b__0()
         at EPiServer.Framework.Cache.ObjectInstanceCacheExtensions.ReadThroughWithWait[T](IObjectInstanceCache cache, String cacheKey, Func`1 readValue, Func`2 evictionPolicy)
      System.NullReferenceException: Object reference not set to an instance of an object.
         at EPiServer.Commerce.Catalog.Provider.MetaDataPropertyMapper.AssignMetaFieldValueToProperty(PropertyData property, Object metaFieldValue, MetaDataType metaDataType, String blockPropertyMetaFieldName)
         at EPiServer.Commerce.Catalog.Provider.Construction.CatalogPropertyLoader.AddMetaDataAttributePropertyValues(MetaObjectAccessor accessor, CatalogContentBase content)
         at EPiServer.Commerce.Catalog.Provider.Construction.CatalogPropertyLoader.LoadMetaDataContentProperties(MetaObjectAccessor accessor, CatalogContentBase content)
         at EPiServer.Commerce.Catalog.Provider.Construction.CatalogPropertyLoader.LoadProperties(CatalogEntryRow entryRow, CatalogItemSeoRow seoRow, VariationRow variationRow, EntryContentBase content, MetaObjectAccessor metaObjectAccessor)
         at EPiServer.Commerce.Catalog.Provider.Construction.EntryBuilder.SetEntryContentProperties(EntryContentBase entry, CatalogEntryRow entryRow, String contentLanguage, MetaObject metaObj, IDictionary`2 versionsForUnpublishedContent, IDictionary`2 primaryNodeRelations)
         at EPiServer.Commerce.Catalog.Provider.Construction.EntryBuilder.ConstructEntries(CatalogEntryDto entryDto, IDictionary`2 versionsForUnpublishedContent, IDictionary`2 primaryNodeRelations, String language)
         at EPiServer.Commerce.Catalog.Provider.Construction.EntryBuilder.Create(IList`1 contentLinks, String language)
         at EPiServer.Commerce.Catalog.Provider.CatalogContentLoader.<>c__DisplayClass9_0.<LoadSpecificContentInstances>b__0(ICatalogContentBuilder builder, IList`1 links)
         at EPiServer.Commerce.Catalog.Provider.CatalogContentLoader.ConstructContent(IList`1 contentLinks, Func`3 createContentFunc)
         at EPiServer.Commerce.Catalog.Provider.CatalogContentLoader.LoadSpecificContentInstances(IList`1 contentLinks, String language)
         at EPiServer.Commerce.Catalog.Provider.CatalogContentProvider.<>c__DisplayClass29_0.<LoadContents>b__1(IList`1 refs)
         at EPiServer.Commerce.Catalog.Provider.CatalogContentProvider.BatchLoad(IList`1 contentLinks, Func`2 dbLoader)
         at EPiServer.Commerce.Catalog.Provider.CatalogContentProvider.LoadContents(IList`1 contentReferences, ILanguageSelector selector)
         at EPiServer.Commerce.Catalog.Provider.CatalogContentProvider.LoadContent(ContentReference contentLink, ILanguageSelector languageSelector)
         at EPiServer.Core.ContentProvider.<>c__DisplayClass123_0.<LoadContentFromCacheOrRepository>b__0()
         at EPiServer.Framework.Cache.ObjectInstanceCacheExtensions.ReadThroughWithWait[T](IObjectInstanceCache cache, String cacheKey, Func`1 readValue, Func`2 evictionPolicy)

Middleware Error

Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
      An unhandled exception has occurred while executing the request.
      System.NullReferenceException: Object reference not set to an instance of an object.
         at EPiServer.Commerce.Catalog.Provider.MetaDataPropertyMapper.AssignMetaFieldValueToProperty(PropertyData property, Object metaFieldValue, MetaDataType metaDataType, String blockPropertyMetaFieldName)
         at EPiServer.Commerce.Catalog.Provider.Construction.CatalogPropertyLoader.AddMetaDataAttributePropertyValues(MetaObjectAccessor accessor, CatalogContentBase content)
         at EPiServer.Commerce.Catalog.Provider.Construction.CatalogPropertyLoader.LoadMetaDataContentProperties(MetaObjectAccessor accessor, CatalogContentBase content)
         at EPiServer.Commerce.Catalog.Provider.Construction.CatalogPropertyLoader.LoadProperties(CatalogEntryRow entryRow, CatalogItemSeoRow seoRow, VariationRow variationRow, EntryContentBase content, MetaObjectAccessor metaObjectAccessor)
         at EPiServer.Commerce.Catalog.Provider.Construction.EntryBuilder.SetEntryContentProperties(EntryContentBase entry, CatalogEntryRow entryRow, String contentLanguage, MetaObject metaObj, IDictionary`2 versionsForUnpublishedContent, IDictionary`2 primaryNodeRelations)
         at EPiServer.Commerce.Catalog.Provider.Construction.EntryBuilder.ConstructEntries(CatalogEntryDto entryDto, IDictionary`2 versionsForUnpublishedContent, IDictionary`2 primaryNodeRelations, String language)
         at EPiServer.Commerce.Catalog.Provider.Construction.EntryBuilder.Create(IList`1 contentLinks, String language)
         at EPiServer.Commerce.Catalog.Provider.CatalogContentLoader.<>c__DisplayClass9_0.<LoadSpecificContentInstances>b__0(ICatalogContentBuilder builder, IList`1 links)
         at EPiServer.Commerce.Catalog.Provider.CatalogContentLoader.ConstructContent(IList`1 contentLinks, Func`3 createContentFunc)
         at EPiServer.Commerce.Catalog.Provider.CatalogContentLoader.LoadSpecificContentInstances(IList`1 contentLinks, String language)
         at EPiServer.Commerce.Catalog.Provider.CatalogContentProvider.<>c__DisplayClass29_0.<LoadContents>b__1(IList`1 refs)
         at EPiServer.Commerce.Catalog.Provider.CatalogContentProvider.BatchLoad(IList`1 contentLinks, Func`2 dbLoader)
         at EPiServer.Commerce.Catalog.Provider.CatalogContentProvider.LoadContents(IList`1 contentReferences, ILanguageSelector selector)
         at EPiServer.Commerce.Catalog.Provider.CatalogContentProvider.LoadContent(ContentReference contentLink, ILanguageSelector languageSelector)
         at EPiServer.Core.ContentProvider.<>c__DisplayClass123_0.<LoadContentFromCacheOrRepository>b__0()
         at EPiServer.Framework.Cache.ObjectInstanceCacheExtensions.ReadThroughWithWait[T](IObjectInstanceCache cache, String cacheKey, Func`1 readValue, Func`2 evictionPolicy)
         at EPiServer.Framework.Cache.ObjectInstanceCacheExtensions.ReadThrough[T](IObjectInstanceCache cache, String key, Func`1 readValue, Func`2 evictionPolicy, ReadStrategy readStrategy)
         at EPiServer.Core.Internal.ContentInstanceCache.ReadThrough(ContentReference contentLink, String selectedLanguage, Func`1 readValue)
         at EPiServer.Core.ContentProvider.LoadContentFromCacheOrRepository(ContentReference contentreference, ILanguageSelector selector)
         at EPiServer.Core.Internal.ProviderPipelineImplementation.GetItem(ContentProvider provider, ContentReference contentLink, LoaderOptions loaderOptions)
         at EPiServer.Core.Internal.DefaultContentLoader.TryGet[T](ContentReference contentLink, LoaderOptions loaderOptions, T& content)
         at EPiServer.Core.Internal.DefaultContentLoader.Get[T](ContentReference contentLink, LoaderOptions loaderOptions)
         at EPiServer.Core.Internal.DefaultContentLoader.Get[T](ContentReference contentLink)
         at EPiServer.Core.Internal.DefaultContentRepository.Get[T](ContentReference contentLink)
         at EPiServer.Cms.Shell.UI.Rest.ContentQuery.Internal.DefaultContentQueryHelper.FilterNewerPublishedVersion(IEnumerable`1 items, Nullable`1 requestTime)+MoveNext()
         at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
         at System.Linq.Enumerable.<Any>g__WithEnumerator|36_0[TSource](IEnumerable`1 source)
         at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source)
         at EPiServer.Cms.Shell.UI.Rest.ContentQuery.Internal.DefaultContentQueryHelper.FilterAccess(IEnumerable`1 items, AccessLevel requiredAccess)
         at EPiServer.Cms.Shell.UI.Rest.ContentQuery.ContentActivitiesQueryBase.Filter(IEnumerable`1 items, ContentQueryParameters parameters)
         at EPiServer.Cms.Shell.UI.Rest.ContentQuery.Internal.ContentActivitiesNotReadyQuery.Filter(IEnumerable`1 items, ContentQueryParameters parameters)
         at EPiServer.Cms.Shell.UI.Rest.ContentQuery.ContentActivitiesQueryBase.ExecuteQuery(IQueryParameters parameters)
         at EPiServer.Cms.Shell.UI.Rest.Internal.ContentStore.Get(ContentReference id, String query, ContentReference referenceId, ContentReference[] references, String[] typeIdentifiers, Nullable`1 allLanguages, String propertyName, ContentReference ownerContentLink, IEnumerable`1 sortColumns, ContentReference selectedContentReference, ItemRange range)
         at lambda_method923(Closure, Object, Object[])
         at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncActionResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()
      --- End of stack trace from previous location ---
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
      --- End of stack trace from previous location ---
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
      --- End of stack trace from previous location ---
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
         at ProjectName.Features.Search.SearchTrackingMiddleware.Invoke(HttpContext context, ISearchTracker searchTracker, ILogger`1 logger) in C:\Projects\ProjectName\src\ProjectName.Features\Search\SearchTrackingMiddleware.cs:line 38
         at Stott.Security.Optimizely.Features.Middleware.SecurityHeaderMiddleware.Invoke(HttpContext context, IHeaderCompilationService securityHeaderService)
         at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
         at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
         at SixLabors.ImageSharp.Web.Middleware.ImageSharpMiddleware.Invoke(HttpContext httpContext, Boolean retry)
         at Geta.NotFoundHandler.Infrastructure.Initialization.NotFoundHandlerMiddleware.InvokeAsync(HttpContext context, RequestHandler requestHandler)
         at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
         at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)
#325997
Jul 25, 2024 11:28
Vote:
 

Hi,

I saw in your error log then the issue happened when loading properties for content "68__CatalogContent" in language "en". Just try to configure Logger with Debug level first and see the log to check which  the error was throwed from which property. The debug message should be "Calling  'AssignMetaFieldValueToProperty'..."

#326099
Edited, Jul 27, 2024 7:49
Vote:
 

Looks like some property data is corrupted. Did you change type of a property without updating the values?

You might want to pull a new database copy to your development environment.

#326143
Jul 28, 2024 8:59
* 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.