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

Check if PublishedPropertyType modelType is null #13553

Conversation

CyberReiter
Copy link
Contributor

If there's an existing issue for this PR then this fixes #13515

Description

Adding a null check for the modeltype right after the PropertyValueConverter has been called to check if a type has been set.
That the type returned is null should never happen when using default PropertyValueConverters but if you are using a custom PropertyValueConverter there could be a chance that null is returned.
Sadly we only have the Id of the datatype available, but thats still better than nothing.

@nul800sebastiaan nul800sebastiaan changed the base branch from v11/contrib to contrib January 26, 2023 14:41
@JasonElkin JasonElkin self-assigned this Mar 6, 2023
Copy link
Contributor

@JasonElkin JasonElkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much @CyberReiter for taking a look at this.

Though this is a bug/problem with the Property Value Converter, we don't really want to throw here because we can gracefully fall back to typeof(object).

Strictly speaking, there's no need for a Property Value Converter for a given property, hence the fallback, so it makes sense to treat a null type the same way we would when there is no converter at all.

If you're happy to change it to return typeof(object) (I've added an example) that would be amazing, otherwise let me know and I can do it and we'll get this fix merged in ASAP.

Copy link
Contributor

@JasonElkin JasonElkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works like a charm. Thanks @CyberReiter.

@JasonElkin JasonElkin merged commit 0cfc1fb into umbraco:contrib Mar 8, 2023
13 checks passed
@JasonElkin JasonElkin removed their assignment Mar 8, 2023
nul800sebastiaan pushed a commit that referenced this pull request Mar 17, 2023
* add null check

* return object when type is null

(cherry picked from commit 0cfc1fb)
@nul800sebastiaan
Copy link
Member

Cherry picked for 10.5 in 5fcbd4e

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

Successfully merging this pull request may close these issues.

Model's builder doesn't nicely catch a type error making it hard to debug an data type issue.
3 participants