Try our conversational search powered by Generative AI!

Null reference exception in ContentTypeStore when null value passed to ImageAttribute on the model

Fixed in

EPiServer.CMS.UI 10.6.1

(Or a related package)

Created

Feb 21, 2017

Updated

Feb 27, 2017

Area

CMS UI

State

Closed, Fixed and tested


Description

Steps to reproduce

  1. Add [ImageAttribute(null)] to a page, for example, the StartPage in AlloyMVC.
  2. Build and load the Edit UI.

Expected:
The ContentType store should not return a 500. It should handle the case that the path is null.

Actual:
A null reference exception is thrown in EPiServer.Cms.Shell.UI.Rest.ContentTypeStore.GetImagePath when trying to resolve the AppRelative path using a null value.

http://world.episerver.com/forum/developer-forum/-Episerver-75-CMS/Thread-Container/2017/2/error-when-creating-a-new-block/

[ArgumentNullException: Value cannot be null.
Parameter name: virtualPath]
System.Web.VirtualPath.Create(String virtualPath, VirtualPathOptions options) +9936421
System.Web.VirtualPathUtility.IsAppRelative(String virtualPath) +14
EPiServer.Cms.Shell.UI.Rest.ContentTypeStore.GetImagePath(ContentType type) +141
EPiServer.Cms.Shell.UI.Rest.ContentTypeStore.ToContentTypeViewModel(ContentType type) +358
System.Linq.WhereSelectListIterator`2.MoveNext() +115
Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeList(JsonWriter writer, IEnumerable values, JsonArrayContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty) +475
Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(JsonWriter writer, Object value, JsonContract valueContract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerProperty) +332
Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType) +220
Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType) +824
EPiServer.Framework.Serialization.Json.JsonObjectSerializer.Serialize(TextWriter textWriter, Object value) +51
EPiServer.Shell.Services.Rest.RestResultBase.ExecuteResult(ControllerContext context) +222
EPiServer.Shell.Services.Rest.RestResult.ExecuteResult(ControllerContext context) +18
System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +15
System.Web.Mvc.<>c_DisplayClass1a.b_17() +23
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +242
System.Web.Mvc.<>c_DisplayClass1c.b_19() +25
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +242
System.Web.Mvc.<>c_DisplayClass1c.b_19() +25
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +242
System.Web.Mvc.<>c_DisplayClass1c.b_19() +25
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +175
System.Web.Mvc.Async.<>c_DisplayClass2a.b_20() +89
System.Web.Mvc.Async.<>c_DisplayClass25.b_22(IAsyncResult asyncResult) +102
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +58
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +44
EPiServer.Shell.Services.Rest.RestControllerBase.EndExecute(IAsyncResult asyncResult) +38
EPiServer.Shell.Services.Rest.RestHttpHandler.EndProcessRequest(IAsyncResult result) +28
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9765121
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155