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

Fix NRE with TaxonomyIndex #11283

Merged
merged 7 commits into from
Feb 28, 2022
Merged

Fix NRE with TaxonomyIndex #11283

merged 7 commits into from
Feb 28, 2022

Conversation

Skrypt
Copy link
Contributor

@Skrypt Skrypt commented Feb 28, 2022

When a Taxonomy Field is removed from a Content Type. Cloning the content item may fail with an NRE.

/cc @ns8482e

Copy link
Contributor

@ns8482e ns8482e left a comment

Choose a reason for hiding this comment

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

LGTM

@netwavebe
Copy link
Contributor

Hi @Skrypt, turns out it has nothing to do with the removed taxonomy field.

The index runs while cloning, right after an empty content item was created (so before the.actual cloning). The fields are there, but all ´null´. Casting this to JObject fails, as null is a JValue.

I locally fixed this by changing

var jField = (JObject)jPart[fieldDefinition.Name];

to

var jField = jPart[fieldDefinition.Name] as JObject;

@Skrypt
Copy link
Contributor Author

Skrypt commented Feb 28, 2022

Yes, I think this would work still with fewer lines.

Copy link
Contributor

@netwavebe netwavebe left a comment

Choose a reason for hiding this comment

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

All good!

@Skrypt Skrypt merged commit b450318 into main Feb 28, 2022
@Skrypt Skrypt deleted the skrypt/taxonomyindex-nre branch February 28, 2022 20:31
@mwpowellhtx
Copy link
Contributor

My two cents, does not look as though it is an as issue so much as potentially fieldDefinition itself could be null? That or perhaps an indexing issue, depending on the part indexer implementation handles keys, lookups, etc. i.e. mentioned removed taxonomy, i.e. fieldDefinition which to me says fieldDefinition?.Name is more appropriate? Again, my two cents. Good hunting!

@Skrypt
Copy link
Contributor Author

Skrypt commented Mar 19, 2022

We are looping inside a collection of fieldDefinition so it is impossible that the object be null else it would not be part of the IEnumerable.

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

Successfully merging this pull request may close these issues.

None yet

4 participants