Kafka Error INVALID_RECORD
Error code 87 · Non-retriable Producer
This record has failed the validation on broker and hence will be rejected.
Common Causes
- A buggy or custom client sent a malformed record batch that fails broker-side validation (for example invalid batch metadata or record framing)
- Compacted topic received a record with a null key, which is rejected when cleanup.policy=compact since null keys cannot be compacted
- Record batch contains timestamps that violate message.timestamp.before.max.ms or message.timestamp.after.max.ms when message.timestamp.type=CreateTime
Solutions
- For null-key rejections on compacted topics: ensure all producers set a non-null record key before publishing to compacted topics
- For timestamp violations: align producer clock with NTP, or relax message.timestamp.before.max.ms or message.timestamp.after.max.ms on the topic if skew or replayed timestamps are expected
- Check broker logs for the specific validation failure message — it will identify whether the rejection is key-related, size-related, or timestamp-related, then fix the producer accordingly
Diagnostic Commands
# Check Kafka configuration
kafka-configs.sh --bootstrap-server localhost:9092 --entity-type topics --entity-name <topic> --describe | grep -E 'cleanup.policy|max.message.bytes|message.timestamp'
# Look for corruption or validation errors
grep 'INVALID_RECORD\|record validation\|InvalidRecordException' /var/log/kafka/server.log | tail -50Related APIs
This error can be returned by: Produce
Debugging Kafka errors? Conduktor Console gives you real-time visibility into your cluster. Explore all errors in the Error Decoder.