Skip to content

GetModelContentType throws ArgumentNullException #222

Open
@ronaldbarendse

Description

@ronaldbarendse

While trying to get a property alias within Examines TransformingIndexValues event using Project.GetModelPropertyType(p => p.Products).Alias, I get an ArgumentNullException.

Looking at the source, this method requires an UmbracoContext that's not available while this event is fired. The fixme inject! comment probably says enough:

https://github.com/zpqrtbnk/Zbu.ModelsBuilder/blob/bf0da79aee8f52ec153bbb200131d1914ee95b2b/src/Umbraco.ModelsBuilder/Umbraco/PublishedModelUtility.cs#L27-L33

It should probably inject an IUmbracoContextAccessor somewhere and ensure the context exists, allow passing in a custom IPublishedSnapshot or at least return null instead of throwing this exception.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions