mikeedwards83 / Glass.Mapper

Version 5 of the Glass mapping framework, the best ORM for Sitecore.
Apache License 2.0
124 stars 120 forks source link

Sitecore 10.4, NullReferenceException with GetRenderingParameters() #463

Open fredlebel opened 1 month ago

fredlebel commented 1 month ago

The regression is triggered by using Glass Mapper's function to get strongly typed rendering parameters. Html.Glass().GetRenderingParameters<SomeGlassType>()

If the Glass type has a Url field:

[SitecoreInfo(SitecoreInfoType.Url)]
public virtual string Url { get; private set; }

Then GlassMapper ends up calling the following function in Sitecore.Kernel.dll: Sitecore.Links.UrlBuilders.ItemUrlBuilder.Build()

In an earlier version Sitecore.Kernel.dll(16.0.0.0) this function would return string.Empty after checking if the item's path is null. But in the newer version, Sitecore.Kernel.dll(19.0.0.0), an exception is thrown before reaching a similar check.

This seems like Sitecore tripping on the fake item created by Glass when mapping the rendering parameters in RenderingParametersModelFactory.cs.

Item item = Utilities.CreateFakeItem(null, renderParametersTemplateId, _sitecoreService.Database, "renderingParameters");

Versions

Call stack

Sitecore.Kernel.dll!Sitecore.Links.UrlBuilders.Helpers.ItemPathBuilder.GetRelativePath(Sitecore.Data.Items.Item item, Sitecore.Web.SiteInfo site)
Sitecore.Kernel.dll!Sitecore.Links.UrlBuilders.Helpers.ItemPathBuilder.Build(Sitecore.Data.Items.Item item, Sitecore.Web.SiteInfo site)
Sitecore.Kernel.dll!Sitecore.Links.UrlBuilders.ItemUrlBuilder.UpdateItemPathParts(Sitecore.Data.Items.Item item, Sitecore.Links.UrlBuilders.BaseUrlBuilder<Sitecore.Links.UrlBuilders.ItemUrlBuilderOptions>.UrlBuildModel model, Sitecore.Links.UrlBuilders.ItemUrlBuilderOptions options)
Sitecore.Kernel.dll!Sitecore.Links.UrlBuilders.ItemUrlBuilder.Build(Sitecore.Data.Items.Item item, Sitecore.Links.UrlBuilders.ItemUrlBuilderOptions options)
Glass.Mapper.Sc.dll!Glass.Mapper.Sc.SitecoreVersionAbstractions.GetItemUrl(Sitecore.Data.Items.Item item, Sitecore.Links.UrlOptions urlOptions)
Glass.Mapper.Sc.dll!Glass.Mapper.Sc.DataMappers.SitecoreInfoMapper.Setup.AnonymousMethod__9(Sitecore.Data.Items.Item item, Glass.Mapper.Sc.GetOptionsSc getOptions)
Glass.Mapper.Sc.dll!Glass.Mapper.Sc.DataMappers.SitecoreInfoMapper.MapToProperty(Glass.Mapper.AbstractDataMappingContext mappingContext)
Glass.Mapper.dll!Glass.Mapper.AbstractDataMapper.MapCmsToProperty(Glass.Mapper.AbstractDataMappingContext mappingContext)
Glass.Mapper.dll!Glass.Mapper.Configuration.AbstractTypeConfiguration.MapPropertiesToObject(object obj, Glass.Mapper.IAbstractService service, Glass.Mapper.AbstractTypeCreationContext context)
Glass.Mapper.dll!Glass.Mapper.Pipelines.ObjectConstruction.Tasks.CreateConcrete.CreateConcreteTask.CreateObjectAndMapProperties(Glass.Mapper.Pipelines.ObjectConstruction.ObjectConstructionArgs args)
Glass.Mapper.dll!Glass.Mapper.Pipelines.ObjectConstruction.Tasks.CreateConcrete.CreateConcreteTask.Execute(Glass.Mapper.Pipelines.ObjectConstruction.ObjectConstructionArgs args)
Glass.Mapper.dll!Glass.Mapper.Pipelines.AbstractPipelineRunner<Glass.Mapper.Pipelines.ObjectConstruction.ObjectConstructionArgs, Glass.Mapper.Pipelines.ObjectConstruction.AbstractObjectConstructionTask>..ctor.AnonymousMethod__1(Glass.Mapper.Pipelines.ObjectConstruction.ObjectConstructionArgs args)
Glass.Mapper.dll!Glass.Mapper.Pipelines.AbstractPipelineTask<Glass.Mapper.Pipelines.ObjectConstruction.ObjectConstructionArgs>.Next(Glass.Mapper.Pipelines.ObjectConstruction.ObjectConstructionArgs args)
Glass.Mapper.dll!Glass.Mapper.Pipelines.AbstractPipelineTask<Glass.Mapper.Pipelines.ObjectConstruction.ObjectConstructionArgs>.Execute(Glass.Mapper.Pipelines.ObjectConstruction.ObjectConstructionArgs args)
Glass.Mapper.Sc.dll!Glass.Mapper.Sc.Pipelines.ObjectConstruction.EnforcedTemplateCheck.PerformTemplateCheck(Glass.Mapper.Pipelines.ObjectConstruction.ObjectConstructionArgs args, Sitecore.Data.ID templateId, Glass.Mapper.Sc.Configuration.SitecoreEnforceTemplate enforceTemplate)
Glass.Mapper.Sc.dll!Glass.Mapper.Sc.Pipelines.ObjectConstruction.EnforcedTemplateCheck.Execute(Glass.Mapper.Pipelines.ObjectConstruction.ObjectConstructionArgs args)
Glass.Mapper.dll!Glass.Mapper.Pipelines.AbstractPipelineRunner<Glass.Mapper.Pipelines.ObjectConstruction.ObjectConstructionArgs, Glass.Mapper.Pipelines.ObjectConstruction.AbstractObjectConstructionTask>..ctor.AnonymousMethod__1(Glass.Mapper.Pipelines.ObjectConstruction.ObjectConstructionArgs args)
Glass.Mapper.dll!Glass.Mapper.Pipelines.AbstractPipelineTask<Glass.Mapper.Pipelines.ObjectConstruction.ObjectConstructionArgs>.Next(Glass.Mapper.Pipelines.ObjectConstruction.ObjectConstructionArgs args)
Glass.Mapper.dll!Glass.Mapper.Pipelines.AbstractPipelineTask<Glass.Mapper.Pipelines.ObjectConstruction.ObjectConstructionArgs>.Execute(Glass.Mapper.Pipelines.ObjectConstruction.ObjectConstructionArgs args)
Glass.Mapper.dll!Glass.Mapper.Pipelines.ObjectConstruction.Tasks.CacheCheck.CacheCheckTask.Execute(Glass.Mapper.Pipelines.ObjectConstruction.ObjectConstructionArgs args)
Glass.Mapper.dll!Glass.Mapper.Pipelines.AbstractPipelineRunner<Glass.Mapper.Pipelines.ObjectConstruction.ObjectConstructionArgs, Glass.Mapper.Pipelines.ObjectConstruction.AbstractObjectConstructionTask>..ctor.AnonymousMethod__1(Glass.Mapper.Pipelines.ObjectConstruction.ObjectConstructionArgs args)
Glass.Mapper.dll!Glass.Mapper.Pipelines.AbstractPipelineTask<Glass.Mapper.Pipelines.ObjectConstruction.ObjectConstructionArgs>.Next(Glass.Mapper.Pipelines.ObjectConstruction.ObjectConstructionArgs args)
Glass.Mapper.dll!Glass.Mapper.Pipelines.AbstractPipelineTask<Glass.Mapper.Pipelines.ObjectConstruction.ObjectConstructionArgs>.Execute(Glass.Mapper.Pipelines.ObjectConstruction.ObjectConstructionArgs args)
Glass.Mapper.Sc.dll!Glass.Mapper.Sc.Pipelines.ObjectConstruction.SitecoreItemTask.Execute(Glass.Mapper.Pipelines.ObjectConstruction.ObjectConstructionArgs args)
Glass.Mapper.dll!Glass.Mapper.Pipelines.AbstractPipelineRunner<Glass.Mapper.Pipelines.ObjectConstruction.ObjectConstructionArgs, Glass.Mapper.Pipelines.ObjectConstruction.AbstractObjectConstructionTask>..ctor.AnonymousMethod__1(Glass.Mapper.Pipelines.ObjectConstruction.ObjectConstructionArgs args)
Glass.Mapper.dll!Glass.Mapper.Pipelines.AbstractPipelineTask<Glass.Mapper.Pipelines.ObjectConstruction.ObjectConstructionArgs>.Next(Glass.Mapper.Pipelines.ObjectConstruction.ObjectConstructionArgs args)
Glass.Mapper.Sc.dll!Glass.Mapper.Sc.Pipelines.ObjectConstruction.ItemVersionCountByRevisionTask.Execute(Glass.Mapper.Pipelines.ObjectConstruction.ObjectConstructionArgs args)
Glass.Mapper.dll!Glass.Mapper.Pipelines.AbstractPipelineRunner<Glass.Mapper.Pipelines.ObjectConstruction.ObjectConstructionArgs, Glass.Mapper.Pipelines.ObjectConstruction.AbstractObjectConstructionTask>..ctor.AnonymousMethod__1(Glass.Mapper.Pipelines.ObjectConstruction.ObjectConstructionArgs args)
Glass.Mapper.dll!Glass.Mapper.Pipelines.AbstractPipelineTask<Glass.Mapper.Pipelines.ObjectConstruction.ObjectConstructionArgs>.Next(Glass.Mapper.Pipelines.ObjectConstruction.ObjectConstructionArgs args)
Glass.Mapper.dll!Glass.Mapper.Pipelines.AbstractPipelineTask<Glass.Mapper.Pipelines.ObjectConstruction.ObjectConstructionArgs>.Execute(Glass.Mapper.Pipelines.ObjectConstruction.ObjectConstructionArgs args)
Glass.Mapper.dll!Glass.Mapper.Pipelines.ObjectConstruction.Tasks.DepthCheck.ModelDepthCheck.Execute(Glass.Mapper.Pipelines.ObjectConstruction.ObjectConstructionArgs args)
Glass.Mapper.dll!Glass.Mapper.Pipelines.AbstractPipelineRunner<Glass.Mapper.Pipelines.ObjectConstruction.ObjectConstructionArgs, Glass.Mapper.Pipelines.ObjectConstruction.AbstractObjectConstructionTask>..ctor.AnonymousMethod__1(Glass.Mapper.Pipelines.ObjectConstruction.ObjectConstructionArgs args)
Glass.Mapper.dll!Glass.Mapper.Pipelines.AbstractPipelineTask<Glass.Mapper.Pipelines.ObjectConstruction.ObjectConstructionArgs>.Next(Glass.Mapper.Pipelines.ObjectConstruction.ObjectConstructionArgs args)
Glass.Mapper.Sc.dll!Glass.Mapper.Sc.Pipelines.ObjectConstruction.NullItemTask.Execute(Glass.Mapper.Pipelines.ObjectConstruction.ObjectConstructionArgs args)
Glass.Mapper.dll!Glass.Mapper.Pipelines.AbstractPipelineRunner<Glass.Mapper.Pipelines.ObjectConstruction.ObjectConstructionArgs, Glass.Mapper.Pipelines.ObjectConstruction.AbstractObjectConstructionTask>..ctor.AnonymousMethod__0(Glass.Mapper.Pipelines.ObjectConstruction.ObjectConstructionArgs args)
Glass.Mapper.dll!Glass.Mapper.Pipelines.AbstractPipelineRunner<Glass.Mapper.Pipelines.ObjectConstruction.ObjectConstructionArgs, Glass.Mapper.Pipelines.ObjectConstruction.AbstractObjectConstructionTask>.Run(Glass.Mapper.Pipelines.ObjectConstruction.ObjectConstructionArgs args)
Glass.Mapper.dll!Glass.Mapper.AbstractService.InstantiateObject(Glass.Mapper.AbstractTypeCreationContext abstractTypeCreationContext)
Glass.Mapper.Sc.dll!Glass.Mapper.Sc.SitecoreService.RunCreateType(Sitecore.Data.Items.Item item, Glass.Mapper.GetOptions options, System.Collections.Generic.Dictionary<string, object> parameters)
Glass.Mapper.Sc.dll!Glass.Mapper.Sc.SitecoreService.GetItem(Glass.Mapper.Sc.GetItemOptions options)
Glass.Mapper.Sc.dll!Glass.Mapper.Sc.SitecoreService.GetItem<TGlassType>(Glass.Mapper.Sc.GetItemOptions options)
Glass.Mapper.Sc.dll!Glass.Mapper.Sc.RenderingParametersModelFactory.CreateModel<TGlassType>(System.Collections.Specialized.NameValueCollection parameters, Sitecore.Data.ID renderParametersTemplateId)
Glass.Mapper.Sc.dll!Glass.Mapper.Sc.GlassHtml.GetRenderingParameters<TGlassType>(System.Collections.Specialized.NameValueCollection parameters, Sitecore.Data.ID renderParametersTemplateId)
Glass.Mapper.Sc.dll!Glass.Mapper.Sc.GlassHtml.GetRenderingParameters<TGlassType>(System.Collections.Specialized.NameValueCollection parameters)
Glass.Mapper.Sc.dll!Glass.Mapper.Sc.GlassHtml.GetRenderingParameters<TGlassType>(string parameters)
Glass.Mapper.Sc.Mvc.dll!Glass.Mapper.Sc.Web.Mvc.GlassHtmlMvc<SomeType>.GetRenderingParameters<TGlassType>()
... ASP page ...
girishsharma008 commented 1 month ago

Seems like issue related to glass mapper 10.3 library and upgrade is required.

@mikeedwards83 do we know when Glass Mapper support release planning for Sitecore 10.4

Thanks Girish