`@JsonIgnoreProperties` bypassed for Creator properties with builders and external type ids
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 74/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- java
- Domain
- backend-api-design
Research direction
Start with BeanDeserializer.deserializeUsingPropertyBasedWithExternalTypeId and the two BuilderBasedDeserializer Creator loops, comparing them with the existing guard in deserializeUsingPropertyBased and deserializeUsingPropertyBasedWithUnwrapped. Reproduce the builder, unwrapped, and external-type-id cases from the issue, then verify that ignored creator properties remain unset while the existing plain Creator behavior is unchanged.
Written by the indexing model from the issue text.
Description
Describe the bug
@JsonIgnoreProperties is not applied to Creator properties on three of the property-based-Creator deserialization paths, so a name the annotation lists still gets deserialized and passed to the constructor or builder.
BeanDeserializer checks the ignore set before assigning a Creator property (the [databind#4629] guard, needed because a type with a property-based @JsonCreator resolves a valid creatorProp and so never reaches the by-name ignore check further down the loop). That guard is present in deserializeUsingPropertyBased and deserializeUsingPropertyBasedWithUnwrapped, but not in deserializeUsingPropertyBasedWithExternalTypeId. BuilderBasedDeserializer does not have it on any of its Creator loops (_deserializeUsingPropertyBased, deserializeUsingPropertyBasedWithUnwrapped).
So the ignore configuration works for a plain POJO or record, and stops working for the same type once it is built through a @JsonPOJOBuilder, or once it has an @JsonTypeInfo(include = EXTERNAL_PROPERTY) property.
Version Information
3.2.2-SNAPSHOT (also reproduces on 3.3.0-SNAPSHOT). 3.1 has a narrower, record-only form of the guard, so its behavior differs.
Reproduction
Builder case:
@JsonDeserialize(builder = BuiltValue.Builder.class)
static class BuiltValue {
public final int id;
public final String secret;
BuiltValue(int id, String secret) { this.id = id; this.secret = secret; }
@JsonPOJOBuilder(withPrefix = "")
static class Builder {
private final int id;
private final String secret;
@JsonCreator
public Builder(@JsonProperty("id") int id, @JsonProperty("secret") String secret) {
this.id = id;
this.secret = secret;
}
public BuiltValue build() { return new BuiltValue(id, secret); }
}
}
static class BuilderWrapper {
@JsonIgnoreProperties("secret")
public BuiltValue child;
}
BuilderWrapper w = MAPPER.readValue(
"{\"child\":{\"id\":13,\"secret\":\"leaked\"}}", BuilderWrapper.class);
// w.child.secret is "leaked"; expected null
External type id case:
static abstract class Animal { public String name; }
static class Dog extends Animal { }
static class ExtTypeValue {
public final String secret;
public final Animal value;
@JsonCreator
public ExtTypeValue(@JsonProperty("secret") String secret,
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.EXTERNAL_PROPERTY, property = "type")
@JsonSubTypes({ @JsonSubTypes.Type(value = Dog.class, name = "dog") })
@JsonProperty("value") Animal value) {
this.secret = secret;
this.value = value;
}
}
static class ExtTypeWrapper {
@JsonIgnoreProperties("secret")
public ExtTypeValue child;
}
ExtTypeWrapper w = MAPPER.readValue(
"{\"child\":{\"secret\":\"leaked\",\"type\":\"dog\",\"value\":{\"name\":\"Rex\"}}}",
ExtTypeWrapper.class);
// w.child.secret is "leaked"; expected null
The same thing happens when the builder has @JsonUnwrapped properties, which routes through BuilderBasedDeserializer.deserializeUsingPropertyBasedWithUnwrapped.
Expected behavior
secret should be left unset in all three cases, matching what the plain property-based Creator path already does.
Additional context
The practical impact is that the annotation silently stops filtering input for these shapes, so a property an application deliberately excluded from binding is accepted from the incoming document. Happy to open a PR adding the same guard to the three loops.
- Dominant language
- Java
- Stars
- 3.8k
- Forks
- 1.6k
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 59
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from FasterXML/jackson-databind
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
FasterXML/jackson-databind#6443 ·
Maintainers usually reply within 1 day
-
to-evaluate
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
FasterXML/jackson-databind#6340 · 2 comments ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 12/100
FasterXML/jackson-databind#6442 ·
Maintainers usually reply within 1 day
-
`@JsonUnwrapped` value with `EXTERNAL_PROPERTY` type id silently deserialized as `null` (or misleading unknown-property error)Possibly taken @wn1331 claimed this 2 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 55/100
FasterXML/jackson-databind#6421 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 1-2 days Newbie friendliness 35/100
FasterXML/jackson-databind#6418 · 2 comments ·
Maintainers usually reply within 1 day
All issues in FasterXML/jackson-databind
Similar issues
-
Cleanup: restore the interrupt flag in AiFailureAnalyzerPossibly taken @Rishankgupta08 claimed this today. Opengood first issue
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
seleniumboot/selenium-boot#258 · 1 comment ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
dense-analysis/ale#5181 ·
-
bug subsystem:agent-harness triage
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
ShaftHQ/SHAFT_ENGINE#8043 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
johanhaleby/occurrent#1505 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day