---
title: "RecordDeserializationException in Kafka: causes and fixes"
description: "Why a Kafka consumer stops with RecordDeserializationException after a schema change the registry accepted, and how to upgrade readers in the right order."
url: https://monedula.dev/kafka/troubleshooting/record-deserialization-exception/
---

# RecordDeserializationException: Error deserializing VALUE (Avro schema resolution)

Kafka error · Avro schema resolution · not retriable.

Exception: `org.apache.kafka.common.errors.RecordDeserializationException`

## Quick answer

The consumer fetched a record its value deserializer could not turn into an object, and poll() threw at that offset. With Avro and Schema Registry the usual cause is a schema change the registry accepted that the consumer's reader schema cannot read: under BACKWARD, the default, a producer upgraded before its consumers. Upgrade the consumer's schema, or read with a generic reader.

## What it means

KafkaConsumer runs the key and value deserializers inside poll(). When one throws, the client wraps the failure in a RecordDeserializationException with a message like Error deserializing VALUE for partition orders-0 at offset 1. If needed, please seek past the record to continue consumption. The consumer's position stays at that offset, so the next poll() fails on the same record and the group stops there while lag grows behind it. The cause is the deserializer's own exception. A Confluent Avro deserializer reads the schema id in front of the record, fetches the writer's schema from Schema Registry, and resolves it against the reader schema: the writer's schema itself for a generic reader, the generated class with specific.avro.reader=true, or the subject's latest version with use.latest.version=true. If Avro cannot resolve the two, the deserializer throws a SerializationException, Error deserializing Avro message for id 2, whose cause names the problem, for example Found orders.Order, expecting orders.Order, missing required field note. The registry's compatibility mode only guarantees one direction: BACKWARD, the default, means a consumer on the new schema can read old data, and says nothing about a consumer still on the old schema reading new data. Since Kafka 3.9 the exception also carries the origin (KEY or VALUE), the timestamp and the raw key and value bytes, so a handler can log or dead-letter the record before it seeks past it.

## Likely causes, most common first

1. **Producers were upgraded before consumers under BACKWARD.** BACKWARD accepts a change that removes a field without a default, because a reader on the new schema simply ignores it in old records. A consumer still on the old generated class expects that field in every record and has nothing to fall back to, so it fails at the first record written with the new version.
2. **The subject runs under NONE.** With compatibility switched off the registry stores any change, renames and type changes included. Every consumer with a specific reader that does not match fails on the first new record.
3. **The consumer pins the latest version.** With use.latest.version=true the reader is whatever the subject's latest version is. A new version that cannot read older records breaks a consumer reading from an earlier offset, even though nothing in the consumer was deployed.
4. **The bytes are not what the deserializer expects.** A record written with a different serializer, plain JSON or a string on a topic read with an Avro deserializer, fails before any schema is involved, typically with Unknown magic byte. A schema id the consumer's registry does not know fails with schema not found, also wrapped in a RecordDeserializationException.

## How to fix it

- Upgrade the consumer to a reader schema that reads the new version: regenerate the classes from the latest schema and redeploy. Under BACKWARD a consumer on the new schema reads both old and new records, so the group resumes at the offset it stopped on without losing anything.
- Follow the upgrade order the mode implies: under BACKWARD deploy consumers first and producers after, under FORWARD producers first, and under FULL either order works.
- Read with a generic reader (specific.avro.reader=false, the default) where the code does not need generated classes: it decodes each record with the writer's own schema.
- Test a change against the readers you run, not just the registry: a FULL or FULL_TRANSITIVE subject rejects changes that one side cannot read, at the cost of fewer allowed changes.
- Handle the exception in the poll loop: log the partition and offset from the RecordDeserializationException, send the raw bytes to a dead letter topic if the record must be kept, and only then call seek(partition, offset + 1). Do it on purpose, for a record you know is bad, not to get past a reader that is out of date.

## What not to do

- Seeking past the failing offset to unblock the group after a schema change: every record written with the new version fails the same way, so the consumer skips all of them, not one.
- Switching the subject to NONE so that a change goes through: it removes the check that would have caught the next change a consumer cannot read.

## Does the client retry it?

No. The consumer's position does not move past a record it cannot deserialize, so every poll() fetches the same record and throws again. Only a reader that can read it, or an application that deliberately seeks past the offset, gets the group moving.

## Reproduce it in the simulator

- [Kafka consumer cannot read a new schema under BACKWARD](https://monedula.dev/kafka-simulator/scenarios/consumer-reader-incompatible/) (Backward mode accepts it, an old consumer cannot read it): [open at the moment it happens](https://monedula.dev/kafka-simulator/playground/?scenario=25.1.11&t=3)

## Sources

- [Apache Kafka source: CompletedFetch.java (the RecordDeserializationException message)](https://github.com/apache/kafka/blob/4.4.0/clients/src/main/java/org/apache/kafka/clients/consumer/internals/CompletedFetch.java)
- [KIP-1036: Extend RecordDeserializationException exception](https://cwiki.apache.org/confluence/display/KAFKA/KIP-1036%3A+Extend+RecordDeserializationException+exception)
- [Confluent: schema evolution and compatibility (upgrade order per mode)](https://docs.confluent.io/platform/current/schema-registry/fundamentals/schema-evolution.html)
- [Confluent: Avro serializer and deserializer (specific.avro.reader, use.latest.version)](https://docs.confluent.io/platform/current/schema-registry/fundamentals/serdes-develop/serdes-avro.html)
- [Confluent Schema Registry source: AbstractKafkaAvroDeserializer.java](https://github.com/confluentinc/schema-registry/blob/master/avro-serializer/src/main/java/io/confluent/kafka/serializers/AbstractKafkaAvroDeserializer.java)
- [Apache Avro source: Resolver.java (missing required field)](https://github.com/apache/avro/blob/main/lang/java/avro/src/main/java/org/apache/avro/Resolver.java)

## Related

- [Schema being registered is incompatible (409) in Kafka](https://monedula.dev/kafka/troubleshooting/schema-incompatible/)
- [Schema not found (40403) in Kafka: causes and fixes](https://monedula.dev/kafka/troubleshooting/schema-not-found/)
- [Kafka consumer lag keeps growing: causes and fixes](https://monedula.dev/kafka/troubleshooting/consumer-lag-keeps-growing/)
