Scrivio Interview library
DebuggingFoundations6 min read · updated 13 November 2026

A sink connector reads JSON events produced by a Spring Boot service with JsonSerializer and fails at once with DataException: JsonConverter with schemas.enable requires "schema" and "payload" fields and may not contain additional fields.

Explain the error, the quick fix, and why the quick fix may not be enough for a JDBC sink.

JsonConverter with schemas.enable=true, its default, expects every message to be an envelope with a schema field and a payload field; a Spring Boot JsonSerializer writes plain JSON, so conversion fails before the connector sees the record. The quick fix is value.converter.schemas.enable=false, which delivers schemaless maps. That is often not enough for a JDBC sink, which needs a schema to map fields to typed columns, so the lasting fix is a schema-aware format with a schema registry.

Why this question is asked

A mismatch between what producers write and what Connect expects is the most common reason a new connector fails on its first record, and this exact error message is one most Kafka engineers meet early. Interviewers ask about it to see whether we understand what a converter does, why the quick fix works, and why it may only move the problem further down the pipeline. In this answer, we will recap converters, look at the bytes the producer wrote and the bytes the converter expected, apply the quick fix, see why a JDBC sink still needs a schema, and choose a lasting format.

1A Quick Recap of Converters

Kafka stores records as bytes. Kafka Connect works with its own data model, a value plus an optional schema that describes its fields and types. A converter translates between the two: for a sink connector it turns the key and value bytes from the topic into Connect data before transforms and the connector run.

Converters are configured per worker with key.converter and value.converter, and any connector can override them with the same settings in its own config. JsonConverter is the built-in choice for JSON. Its schemas.enable option decides whether it expects each message to carry its own schema, and it defaults to true.

2Why the Conversion Fails

With schemas.enable=true, JsonConverter expects every message to be an envelope with exactly two fields: schema, describing the types, and payload, holding the data. The Spring Boot service, however, uses JsonSerializer, which writes the object's fields directly.

Java
# what JsonSerializer wrote
{"orderId": "o-1001", "amount": 49.90, "status": "PAID"}
# what JsonConverter with schemas.enable=true expects
{"schema": {"type": "struct", "fields": [
{"field": "orderId", "type": "string"},
{"field": "amount", "type": "double"},
{"field": "status", "type": "string"}]},
"payload": {"orderId": "o-1001", "amount": 49.90, "status": "PAID"}}
# result: DataException: JsonConverter with schemas.enable requires "schema" and "payload" fields ...

The converter finds orderId, amount and status at the top level instead of schema and payload, and rejects the record. Notice that this happens in the converter, before any transform or the connector itself runs, which is why the task fails at once on the very first record.

3The Quick Fix

We tell the converter that messages carry no envelope. If keys are JSON too, the key converter needs the same setting; if keys are plain strings, StringConverter is the right key converter.

Properties
value.converter=org.apache.kafka.connect.json.JsonConverter
value.converter.schemas.enable=false
key.converter=org.apache.kafka.connect.storage.StringConverter
# the connector now receives each value as a schemaless Map: {orderId=o-1001, amount=49.9, status=PAID}

Now conversion succeeds. Connectors that do not care about types, such as an object storage sink writing JSON files, will work fine with this.

4Why a JDBC Sink May Still Fail

A JDBC sink maps each field to a column of a specific SQL type, and when auto.create is on, it creates the table from the schema. With schemaless maps there is no schema: the connector does not know whether amount is a decimal, a double or a string, or which fields are required. Most JDBC sinks therefore reject schemaless values, typically with an error that a schema is required, or cannot create the table. So the quick fix turns a converter error into a connector error.

There are two ways to give the sink a schema. Producers can include it in the envelope, which works but repeats the full schema in every message and makes them several times larger. The better way is a schema-aware format with a schema registry: Avro, Protobuf or JSON Schema, each with a serializer in the producer and a matching converter in Connect. The schema is stored once in the registry, and each message carries only a small id.

Format choices for this pipeline
Producer writesConnect converterJDBC sink?
Plain JSON (JsonSerializer)JsonConverter, schemas.enable=falseUsually fails: no schema
JSON envelope with schemaJsonConverter, schemas.enable=trueWorks; large messages
Avro with schema registryAvroConverter + registry URLWorks; compact, evolvable
JSON Schema with schema registryJsonSchemaConverter + registry URLWorks; stays readable JSON

5Fixing It Properly and Documenting Formats

In the Spring Boot service we would switch the value serializer to the registry-aware one for the chosen format and point it at the registry; in the connector we set the matching converter. Schema evolution rules in the registry then stop a producer from making an incompatible change that would break the sink.

It is also worth knowing what errors.tolerance=all with a DLQ would have done here: every record would fail conversion and be routed to the DLQ instead of failing the task. That is helpful for an occasional bad record, but for a systematic mismatch it hides the problem: the task looks healthy while every record goes to the DLQ. That is why a growing DLQ needs an alert. The broader lesson is to document every topic's key and value format, because converter mismatches are the most common Connect failure.

6Follow-up questions

How do the bytes of a record from a schema-registry Avro serializer start?

With a magic byte of 0, followed by a 4-byte big-endian schema id, followed by the Avro binary encoding of the value. The converter reads the id, fetches that schema from the registry (and caches it), and decodes the rest. That is why reading such a topic with a plain Avro decoder or JsonConverter fails: the first five bytes are not part of the Avro data.

Can one connector read topics with different formats?

Only if they share a converter configuration, since converters are set per connector. Mixed formats usually mean separate connectors, or fixing the producers so one topic family has one format.

Is JSON Schema better than Avro for this?

Both work. JSON Schema keeps messages human-readable and suits teams already on JSON; Avro is more compact and has mature tooling. The important part is using a registry, not which of the two we pick.

7Conclusion

In this answer, we saw that JsonConverter with schemas.enable=true expects a schema and payload envelope, so plain JSON from JsonSerializer fails in the converter before the connector runs. Setting schemas.enable=false fixes conversion, but a JDBC sink needs a schema to map typed columns, so the lasting fix is Avro, Protobuf or JSON Schema with a schema registry, or producers that include schemas. Converters are set per worker and overridable per connector, and a DLQ would hide a systematic mismatch rather than fix it.

What to say in the interviewAbout 80 seconds aloud

Open with

The JsonConverter has schemas.enable set to true by default, which means it expects every message to be an envelope with a schema field and a payload field. The Spring Boot service uses JsonSerializer, which writes plain JSON without that envelope, so the converter rejects the record before the connector even sees it, and the task fails on the first message.

Then, if they want more

The quick fix is to set value.converter to JsonConverter with value.converter.schemas.enable=false, and the same for the key converter if keys are JSON. Then the connector receives schemaless maps.

That works for sinks that do not care about types, but a JDBC sink maps fields to typed columns and may create tables from the schema, so with schemaless data it typically fails or cannot create the table.

The proper fix is a schema-aware format with a schema registry, Avro, Protobuf or JSON Schema with their serializers and converters, or having producers include the schema envelope, which is much larger.

Converters are set per worker and can be overridden per connector, and a mismatch between what producers write and the configured converter is the most common Connect failure, so I would document every topic's format. A DLQ with errors.tolerance=all would only route every record there and hide the mismatch.

About this answer

Last updated
13 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.
Official documentation
Apache Kafka documentation
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 "Explain the error, the quick fix, and why the quick fix may not be enough for a JDBC sink.": https://scrivio-interview-library.netlify.app/spring-boot/kafka-streams-connect/d10788f6bd/