Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

ProjectPipeline throws NullReferenceException if ILocalization.Language is null

Fixed in

EPiServer.CMS.Core 10.9.0

(Or a related package)

Created

Apr 06, 2017

Updated

May 08, 2017

Area

CMS Core

State

Closed, Fixed and tested


Description

A custom provider that does not return language results in a NullReferenceException in ProjectPipeline. Even though ProjectPipeline is not the problem, it should not throw an NullReferenceException.

The problem is that a custom provider should never return a content instance where Language is null. This is not a supported scenario. If it is ILocalizable, it should have a language.

Server Error in '/' Application.
 
Object reference not set to an instance of an object.
 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
 
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
 
Source Error: 
 
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
 
Stack Trace: 
 
 
[NullReferenceException: Object reference not set to an instance of an object.]
   EPiServer.Core.ProjectPipeline.Pipe(ContentReference contentLink, IContent contentInstance, LoaderOptions loaderOptions, Func`3 loadingDelegate) +107
   EPiServer.Core.ProviderPipelineImplementation.GetItem(ContentProvider provider, ContentReference contentLink, LoaderOptions loaderOptions) +488
   EPiServer.Core.DefaultContentLoader.TryGet(ContentReference contentLink, LoaderOptions loaderOptions, T& content) +577
   EPiServer.Core.DefaultContentLoader.Get(ContentReference contentLink, LoaderOptions loaderOptions) +99
   EPiServer.Core.ContentLanguageSettingsHandler.GetClosestSettingNoCache(ContentReference contentLink, Dictionary`2 allSettings) +137
   System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory) +84
   EPiServer.Core.ContentLanguageSettingsHandler.Get(ContentReference contentLink) +95
   EPiServer.Core.ContentLanguageSettingsHandler.Get(ContentReference contentLink, String languageBranch) +23
   EPiServer.Core.LanguagePipeline.CreateSettings(IList`1 contents, CultureInfo language, Int32& maxFallbackLength) +237
   EPiServer.Core.LanguagePipeline.Pipe(IList`1 contentInstances, LoaderOptions loaderOptions, Func`3 loadingDelegate) +307
   EPiServer.Core.ProviderPipelineImplementation.GetItems(ContentProvider provider, IList`1 contentLinks, LoaderOptions loaderOptions) +463
   EPiServer.Core.DefaultContentLoader.GetChildren(ContentReference contentLink, LoaderOptions loaderOptions, Int32 startIndex, Int32 maxRows) +2161
   EPiServer.Core.DefaultContentLoader.GetChildren(ContentReference contentLink, LoaderOptions loaderOptions) +98
 
[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0
   System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) +128
   System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +146
   EPiServer.Cms.Shell.UI.Rest.ContentQuery.ContentQueryBase.GetChildrenByType(Type type, ContentReference parentLink, ILanguageSelector selector) +236
   System.Linq.<SelectManyIterator>d__16`2.MoveNext() +293
   System.Linq.<DistinctIterator>d__63`1.MoveNext() +333
   System.Linq.WhereEnumerableIterator`1.MoveNext() +108
   System.Linq.Enumerable.Any(IEnumerable`1 source) +89
   EPiServer.Cms.Shell.UI.Rest.ContentQuery.DefaultContentQueryHelper.FilterAccess(IEnumerable`1 items, AccessLevel requiredAccess) +57
   EPiServer.Cms.Shell.UI.Rest.ContentQuery.ContentQueryBase.Filter(IEnumerable`1 items, ContentQueryParameters parameters) +95
   EPiServer.Cms.Shell.UI.Rest.ContentQuery.ContentQueryBase.ExecuteQuery(IQueryParameters parameters) +66
   EPiServer.Cms.Shell.UI.Rest.ContentStructureStore.Get(ContentReference id, String query, ContentReference referenceId, String[] typeIdentifiers, Nullable`1 allLanguages, IEnumerable`1 sortColumns, ItemRange range) +413
   lambda_method(Closure , ControllerBase , Object[] ) +437
   System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +229
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +35
   System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState) +39
   System.Web.Mvc.Async.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult) +67
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +42
   System.Web.Mvc.Async.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d() +72
   System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +386
   System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +386
   System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +386
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +42
   System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +38
   System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +186
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +38
   EPiServer.Shell.Services.Rest.RestControllerBase.EndExecute(IAsyncResult asyncResult) +60
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +399
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +137
 
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.1055.0