Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sitecore 10.4, NullReferenceException with GetRenderingParameters() #463

Open
fredlebel opened this issue May 6, 2024 · 1 comment
Open

Comments

@fredlebel
Copy link

fredlebel commented May 6, 2024

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

  • Glass.Mapper.SC: 5.8.181
  • Sitecore.Kernel: 10.4.0

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
Copy link

girishsharma008 commented May 20, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants