Scrivio Interview library
DesignIntermediate7 min read · updated 12 November 2026

Should your API reject unknown fields in requests or ignore them? Discuss for public APIs and for internal events.

There is no single right answer: ignoring unknown fields lets clients and producers add fields without breaking anyone, while rejecting them catches typos and wrong field names early. For events and internal messages we usually ignore unknown fields so additive changes are safe; for public commands with a strict contract, rejecting them can give callers much better feedback. Whatever we choose, we decide it per API and write it down.

Why this question is asked

Every JSON API meets this question sooner or later, usually on the day a client sends a field we do not know. If our service fails, a harmless change on the other side can take us down; if it silently ignores the field, a client may believe a setting was applied when it was not. Interviewers ask it to see whether we think about contracts and change over time rather than about one annotation. In this answer, we will recap how Jackson treats unknown properties, look at the case for ignoring them, then the case for rejecting them, apply both to public APIs and internal events, and finish with how to configure and document the choice.

1A Quick Recap of Unknown Properties in Jackson

An unknown property is a field in the incoming JSON that has no matching property in the Java class we bind it to. Suppose our class has name and email, and the client sends name, email and nickname. Jackson has to decide what to do with nickname.

A plain Jackson ObjectMapper fails by default: DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES is enabled, and Jackson throws an UnrecognizedPropertyException. Spring Boot changes that default. The ObjectMapper that Spring Boot builds disables the feature, so a Spring MVC endpoint ignores unknown fields unless we turn it back on. This difference alone surprises many teams, because a unit test with new ObjectMapper() behaves differently from the running application. Defaults can also shift between major versions, so check your version of Jackson and Spring Boot before relying on either behaviour.

Java
record CustomerRequest(String name, String email) {}
String json = "{\"name\":\"Ann\",\"email\":\"a@x.com\",\"nickname\":\"annie\"}";
new ObjectMapper().readValue(json, CustomerRequest.class);
// UnrecognizedPropertyException: Unrecognized field "nickname"
ObjectMapper lenient = JsonMapper.builder()
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
.build();
lenient.readValue(json, CustomerRequest.class);
// CustomerRequest[name=Ann, email=a@x.com] nickname is dropped

So the same JSON either fails or succeeds depending on one flag. The question is which behaviour serves the people on both sides of the contract.

2The Case for Ignoring: the Tolerant Reader

The tolerant reader idea says a consumer should read only the fields it needs and ignore everything else. The reason is independent change. If a producer adds a field, consumers that do not care about it keep working, and nobody has to coordinate a release across teams.

Consider an order service that publishes OrderPlaced events read by five consumers. The order team adds a loyaltyTier field for one new consumer. If the other four reject unknown fields, they all start failing the moment the new event version is deployed, and the producer has to wait until every consumer has upgraded. With tolerant readers, the producer deploys first, the new consumer starts using the field, and the other four never notice.

Notice that tolerance only works for additive changes. Removing a field, renaming it or changing its type still breaks consumers, whatever this flag says. Ignoring unknown fields is what makes additive change cheap; it does not make every change safe.

3The Case for Rejecting: Catching Mistakes Early

Now take the other side. A client calls our public payment API and sends captureMode instead of capture_mode. With tolerant reading, we ignore the misspelt field, use the default, and capture the payment immediately when the client wanted a delayed capture. The request succeeds with a 201, and the bug shows up days later as a support ticket.

With strict reading, the same request fails at once with a 400 that names the unknown field. The developer sees it on their first test call and fixes the typo in a minute. For commands, requests that ask us to do something with side effects, that early feedback is very valuable. Strictness also stops clients from sending fields they believe we honour, such as a discount field that we never supported.

Java
// What a strict public API can return
// HTTP/1.1 400 Bad Request
// Content-Type: application/problem+json
{
"type": "https://api.example.com/problems/unknown-field",
"title": "Unknown field in request",
"status": 400,
"detail": "Field 'captureMode' is not part of CreatePaymentRequest",
"field": "captureMode"
}

But there is a catch: strict reading makes our own evolution harder in the other direction. If we later add an optional field to the request and a client starts sending it to an older instance during a rolling deployment, the older instance rejects it. Strict APIs therefore need care when we deploy new request fields.

4Public APIs Versus Internal Events

Putting the two cases together gives a reasonable default per kind of traffic. For events and internal messages we ignore unknown fields. Producers and consumers are deployed independently, often by different teams, and messages may sit in a topic for days, so old consumers will read new messages and the other way round. Additive change has to be safe. Validation of the fields we actually use still happens, but extra fields are not an error.

For public commands with a strict contract, rejecting unknown fields gives better feedback, as the payment example showed. Many public APIs still choose tolerance for responses and for read-style requests, because there the risk of a silent misunderstanding is small. The important point is that the choice is made deliberately per API, not left to whichever default the framework happens to ship.

Choosing the unknown-field policy
TrafficPolicyMain reason
Internal events and messagesIgnore unknown fieldsProducers add fields without waiting for consumers
Responses we read from other servicesIgnore unknown fieldsThe other service may add fields at any time
Public commands with side effectsReject unknown fieldsA typo becomes a clear 400, not a silent default
Public queries and filtersUsually rejectAn ignored filter returns wrong data quietly
Internal synchronous commandsEither, documentedSame team often deploys both sides
A starting point per kind of traffic; the contract and its documentation decide in the end.

5Configuring and Documenting the Choice

In Spring Boot we set the global default with spring.jackson.deserialization.fail-on-unknown-properties=true or false, and we override it per type where needed. @JsonIgnoreProperties(ignoreUnknown = true) on a class makes that class tolerant even when the mapper is strict. For the reverse, a strict DTO in a tolerant application, a common approach is a dedicated ObjectReader with the feature enabled, or a small check in a custom request body handler.

Java
# application.properties: strict by default for this public API
spring.jackson.deserialization.fail-on-unknown-properties=true
// An event DTO that must stay tolerant whatever the global setting is
@JsonIgnoreProperties(ignoreUnknown = true)
public record OrderPlaced(String orderId, BigDecimal total) {}

Then we write it down. The OpenAPI description can say additionalProperties: false for strict request schemas, and our API guidelines state the rule for events. A test that sends an extra field and asserts the expected status, 400 or 201, keeps the behaviour from changing by accident during a framework upgrade.

6Follow-up questions

What is the difference between ignoring unknown fields and preserving them?

Ignoring drops the field: the Java object never sees it, and if we serialize the object again the field is gone. Preserving keeps it, for example with @JsonAnySetter collecting unknown fields into a map and @JsonAnyGetter writing them back. A gateway or a service that reads, modifies and writes a document back needs preservation, otherwise it deletes data that newer clients added.

Does ignoring unknown fields make all schema changes backward compatible?

No. It makes adding optional fields safe for old readers. Removing a field that a consumer needs, renaming a field, changing a type from number to string, or making a new field required still breaks consumers. Those changes need a new version of the event or endpoint, or a period where both shapes are supported.

How would you roll out strict reading on an API that was tolerant until now?

Carefully, because some clients may already send fields we ignore. I would first log unknown fields per client for a few weeks without rejecting them, contact the clients that send them, then enable rejection for new API versions or new clients first, and only later for everyone, with an announcement and a date.

7Conclusion

In this answer, we saw that a plain ObjectMapper rejects unknown fields while Spring Boot's ignores them, that ignoring supports the tolerant reader pattern and independent evolution, and that rejecting turns client typos into clear errors. We chose tolerance for events and internal messages, strictness for public commands with strict contracts, and we configured and documented the choice per API with a test to keep it in place.

What to say in the interviewAbout 80 seconds aloud

Open with

I would decide it per API instead of having one global answer. Ignoring unknown fields is the tolerant reader approach: a producer can add a field and old consumers keep working, so teams deploy independently.

Then, if they want more

That is what I want for events and internal messages, where messages live in topics and producers and consumers are always on different versions. Rejecting unknown fields catches typos and wrong names.

On a public command API, if a client sends captureMode instead of capture_mode and I ignore it, the payment is processed with the default and the bug appears days later; if I reject it, they get a 400 naming the field on their first call.

So for public commands with strict contracts I lean towards rejecting, while being careful during rolling deployments when I add new request fields.

In Spring Boot the default is to ignore, unlike a plain ObjectMapper, so I make the choice explicit with the spring.jackson property or per class with JsonIgnoreProperties, document it in the OpenAPI spec with additionalProperties, and add a test that sends an extra field so a framework upgrade cannot change the behaviour silently.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Should your API reject unknown fields in requests or ignore them? Discuss for public...": https://scrivio-interview-library.netlify.app/spring-boot/json-serialization/c1af7f8d86/