Skip to content

Honor @JsonIgnoreProperties for Creator props on builder and external-type-id paths - #6146

Open
aysha-afrah26 wants to merge 3 commits into
FasterXML:3.2from
aysha-afrah26:jsonignoreprops-creator-paths
Open

Honor @JsonIgnoreProperties for Creator props on builder and external-type-id paths#6146
aysha-afrah26 wants to merge 3 commits into
FasterXML:3.2from
aysha-afrah26:jsonignoreprops-creator-paths

Conversation

@aysha-afrah26

Copy link
Copy Markdown
Contributor

Jackson checks the @JsonIgnoreProperties set before assigning a Creator property, since a type with a property-based @JsonCreator resolves a valid creatorProp and so never falls through to the by-name ignore check later in the same loop. That guard reached deserializeUsingPropertyBased and deserializeUsingPropertyBasedWithUnwrapped, but it never reached deserializeUsingPropertyBasedWithExternalTypeId, and BuilderBasedDeserializer carries no copy of it at all. The effect is that ignoring a property works for a plain POJO or record and quietly stops working for the same type once it is built through a @JsonPOJOBuilder, or once it gains an @JsonTypeInfo(include = EXTERNAL_PROPERTY) property, so a value the application excluded from binding is read off the document and handed to the constructor. I noticed it while comparing a builder-backed type with the equivalent plain Creator type and getting different results for identical input. The fix adds the check the sibling loops already use, right after the existing isInjectionOnly test, at the three loops that lack it. Reported separately as #6145, which has a runnable reproduction for each of the three; the new test fails on all three before this change and passes after, and the rest of the suite is unchanged. I left 3.1 alone on purpose, because its copy of the guard is deliberately limited to records, so applying this there would widen behavior instead of closing a gap.

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown

🧪 Code Coverage Report

Metric Coverage Change
Instructions coverage 81.83% 📈 +0.000%
Branches branches 75.45% 📉 -0.010%

Coverage data generated from JaCoCo test results

{"child":{"secret":"leaked","first":"Bob","last":"Smith"}}
""",
UnwrappedBuilderWrapper.class);
assertEquals("Bob", result.child.name.first);

@Dongnyoung Dongnyoung Aug 6, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Minor/optional: Since this test exercises the @JsonUnwrapped path, would it also make sense to assert result.child.name.last == "Smith"? That would explicitly verify that skipping the ignored Creator property doesn't affect deserialization of the remaining unwrapped properties.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good idea, added the last assertion and pushed. Both unwrapped properties come through fine after the ignored Creator prop is skipped.

@cowtowncoder

Copy link
Copy Markdown
Member

@aysha-afrah26 Could this be targeted at 3.1 instead? Or is fix only needed for 3.2?

@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown

🧪 Code Coverage Report

Metric Coverage Change
Instructions coverage 81.85% 📈 +0.000%
Branches branches 75.47% 📉 -0.010%

Coverage data generated from JaCoCo test results

@aysha-afrah26

Copy link
Copy Markdown
Contributor Author

The fix as written really only fits 3.2+: on 3.1 the #4629 guard is still gated on isRecord (records-only by design), so honoring ignoral for regular POJO Creator props is behavior that starts in 3.2, and this PR just extends 3.2's existing guard to the three loops that missed it. Porting it to 3.1 as-is would broaden that records-only behavior on a maintenance branch rather than close a gap, which is why I targeted 3.2. If you do want something on 3.1, the scope-preserving option would be an isRecord-gated check on just the external-type-id loop (builders can't be records, so the other two sites wouldn't apply); happy to put that together if you'd like it there.

@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown

🧪 Code Coverage Report

Metric Coverage Change
Instructions coverage 81.86% 📈 +0.010%
Branches branches 75.49% 📈 +0.010%

Coverage data generated from JaCoCo test results

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.

3 participants