Scrivio Interview library
ScenarioAdvanced7 min read · updated 12 November 2026

A service fails to deserialize events after the producer team added a new enum constant to a shared event schema. Several consumers crashed. How do you fix the incident and prevent recurrence?

Immediately, we stop the bleeding: deploy consumers that tolerate unknown values, by mapping them to an UNKNOWN constant or skipping them to a dead-letter topic, or roll back the producer, remembering that events already in the topic still contain the new value. The root cause is that adding an enum value is a breaking change for consumers that reject unknown values. To prevent a repeat, we set schema evolution rules: consumers must tolerate unknown enum values and producers add values only after consumers are ready, enforced with schema registry compatibility checks in CI and contract tests that send unknown values to every consumer.

Background to this question

An incident like this is a test of two skills at once: calm, ordered incident handling, and the design thinking that stops the same class of failure from happening again. It is also very common, because adding an enum value feels like a backwards-compatible change to the producer team, and in their own code it is. In this answer, we will see why the consumers crashed, handle the incident step by step, including the trap of events already in the topic, and then put rules, tooling and tests in place so a new enum value is a routine change.

1Why the Consumers Crashed

An event schema shared between services often includes an enum, for example an OrderEvent with a status. Each consumer turns the incoming JSON or Avro into its own Java class, and its enum lists the values it knew when it was built. When the producer starts sending ON_HOLD, a value consumers have never seen, their deserializer has no constant to map it to.

Java
// Consumer's model, built before ON_HOLD existed
enum OrderStatus { CREATED, PAID, SHIPPED }
record OrderEvent(String orderId, OrderStatus status) {}
// Incoming: {"orderId":"o-981","status":"ON_HOLD"}
// Jackson: InvalidFormatException: Cannot deserialize value of type `OrderStatus` from String "ON_HOLD"
Step throughA new value blocks a partition
Producerorders topicConsumer
OrderEvent status=ON_HOLD (offset 5012)
deliver offset 5012
InvalidFormatException
no commit; seek back to 5012
deliver offset 5012 again
fails again; offsets 5013+ wait

6 messages in order. Play them, or step through them one at a time.

The bad record never gets past the consumer, so everything behind it waits.

But there is a catch that turns one bad message into an outage. A Kafka consumer reads a partition in order. If the deserialization error is treated as retryable, the consumer retries the same record forever and never reaches the records behind it. If the error crashes the listener container, the service restarts and hits the same record again. Either way, the partition is stuck, and every order behind ON_HOLD is delayed.

2Stop the Bleeding

The first decision is the fastest safe change. Rolling back the producer stops new ON_HOLD events, which is good, but it does not remove the ones already in the topic, so consumers stay stuck on those. The fix that actually unblocks consumers is on the consumer side: make unknown values readable, or move unreadable records out of the way.

Java
// Option A: tolerate unknown values (Jackson 2)
enum OrderStatus { CREATED, PAID, SHIPPED, @JsonEnumDefaultValue UNKNOWN }
// spring.jackson.deserialization.read-unknown-enum-values-using-default-value=true
// or on the consumer's own ObjectMapper:
// mapper.enable(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE)
// Option B: skip poison records to a dead-letter topic (Spring Kafka)
@Bean DefaultErrorHandler errorHandler(KafkaTemplate<Object, Object> template) {
return new DefaultErrorHandler(new DeadLetterPublishingRecoverer(template),
new FixedBackOff(1000L, 2)); // 2 retries, then the dead-letter topic
}
// with ErrorHandlingDeserializer wrapping the JSON deserializer, so failures reach the handler

Option A is usually best for business data, because no event is lost: ON_HOLD becomes UNKNOWN, and the consumer handles it explicitly, for example by holding the order for review and emitting a metric. Option B is the safety net for anything unreadable, so one bad record can never block a partition again. In the incident we often do both: deploy the dead-letter handling first because it is generic and quick, then the tolerant model, then replay the dead-letter topic once consumers understand ON_HOLD. Spring Boot 4 uses Jackson 3, where some of these names moved, so check your version.

3Name the Root Cause Correctly

In the postmortem, it is tempting to blame the producer team for a breaking change, or the consumers for being fragile. The precise root cause is that the contract never said how unknown enum values are handled. In such a contract, adding a value is a breaking change for every consumer that rejects unknown values, and the producer had no way to know which consumers those were. So the fix is a rule in the contract plus tooling that enforces it, not a one-off apology.

Step throughHandling the incident
  1. Detect: consumer lag and error rate alertsorders stuck behind offset 5012
  2. Add dead-letter handling to consumerspartitions move again
  3. Optionally roll back the producerstops new ON_HOLD events; old ones remain
  4. Deploy tolerant consumersON_HOLD -> UNKNOWN, handled explicitly
  5. Replay the dead-letter topicno event is lost
  6. Postmortem: evolution rules and CI checksprevent the next one

6 steps in order. Play them, or step through them one at a time.

4Schema Evolution Rules

Two rules cover enums. First, consumers must tolerate unknown enum values: map them to an explicit UNKNOWN, or skip them with a metric, but never crash or block. Second, producers add a value only after consumers are ready. For a value whose meaning matters, ready means consumers have deployed code that handles it; for informational values, tolerant consumers are enough. The producer announces the new value, consumers deploy, and only then does the producer start sending it, often behind a feature flag.

Removing or renaming a value is treated as breaking under all circumstances, because old events stay in topics and in stored data for as long as retention allows.

5Enforce It With a Schema Registry and Contract Tests

Rules written in a wiki are forgotten. A schema registry stores every version of an event schema and checks each new version against a compatibility rule before it can be used. With Avro, an enum can declare a default symbol that a reader uses when it meets a symbol it does not know, which makes added values readable by old consumers. With Protobuf, unknown enum values are kept as their number and show up in Java as UNRECOGNIZED rather than failing. In both cases, the registry's compatibility check, run in CI for every schema change, rejects changes that would break existing readers. Exactly which enum changes each compatibility mode allows differs between formats and registries, so check yours.

Java
// Avro enum with a default for unknown symbols
{ "type": "enum", "name": "OrderStatus",
"symbols": ["CREATED", "PAID", "SHIPPED", "ON_HOLD", "UNKNOWN"],
"default": "UNKNOWN" }
// Contract test that every consumer must pass
@Test
void toleratesUnknownStatus() {
String json = "{\"orderId\":\"o-1\",\"status\":\"SOME_FUTURE_VALUE\"}";
OrderEvent e = mapper.readValue(json, OrderEvent.class);
assertEquals(OrderStatus.UNKNOWN, e.status()); // no exception
assertDoesNotThrow(() -> handler.handle(e)); // and the handler copes
}

The contract test is the piece that would have caught this incident. Every consumer runs it in its own build, using a value that will never exist, so it checks tolerance in general rather than any specific value. Together with dead-letter handling as a standard part of every consumer template, a new enum value becomes an ordinary release rather than an incident.

6Follow-up questions

Why not just roll back the producer and be done?

Because the events already published still contain ON_HOLD and still block consumers, and because the next addition would cause the same incident. Rollback can reduce the inflow, but the consumers must be fixed to recover the backlog and to stop the class of failure.

Is mapping unknown values to UNKNOWN always safe?

Only when the consumer then handles UNKNOWN deliberately. If the code treats UNKNOWN like some normal value, we have just moved the bug. An exhaustive switch with an explicit UNKNOWN case, plus a metric, keeps it visible.

How do you replay the dead-letter topic safely?

After deploying the tolerant consumer, we republish the dead-letter records to the original topic or read them with a one-off consumer, making sure processing is idempotent so that any record that was partly processed before does not cause duplicates.

7Conclusion

In this answer, we saw that consumers crashed because their enums had no constant for the new value, and that a retried poison record blocked whole partitions. We stopped the incident by adding dead-letter handling and tolerant deserialization with an UNKNOWN constant, used a producer rollback only to reduce inflow, and replayed the dead-letter topic. The root cause was a contract that did not define unknown-value handling, so we set evolution rules, enforce them with schema registry compatibility checks and enum defaults in CI, and require every consumer to pass a contract test with an unknown value.

What to say in the interviewAbout 80 seconds aloud

Open with

First I would stop the bleeding. The consumers are probably stuck retrying one record, because Kafka reads a partition in order, so everything behind the first ON_HOLD event waits.

Then, if they want more

Rolling back the producer stops new ones, but the events already in the topic still block, so the real fix is on the consumer side. Quickest is to add an ErrorHandlingDeserializer and a DefaultErrorHandler with a dead-letter recoverer, so unreadable records go to a dead-letter topic and partitions move again.

Then I deploy consumers that tolerate unknown values: an UNKNOWN constant with Jackson's read-unknown-enum-values-using-default-value, handled explicitly, say hold for review plus a metric. Then I replay the dead-letter topic, with idempotent processing.

In the postmortem, I would name the root cause as the contract: adding an enum value breaks every consumer that rejects unknown values, and nothing defined how unknown values are handled. So we set two rules: consumers must tolerate unknown enum values, and producers only start sending a new value once consumers are ready.

We enforce them with a schema registry and compatibility checks in CI, with Avro enum defaults or Protobuf's unrecognized values, and with a contract test in every consumer that sends a made-up enum value and expects no failure.

About this answer

Last updated
12 November 2026
Versions it names
Spring Boot 4
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 "A service fails to deserialize events after the producer team added a new enum constant...": https://scrivio-interview-library.netlify.app/java/enums/894d96e014/