From dedd86d84f2d56a7c3b604ea36da479c3d2a80bb Mon Sep 17 00:00:00 2001 From: Mark Hindess Date: Tue, 29 Aug 2023 16:25:00 +0100 Subject: [PATCH] fix: make clear that error is configuration issue not server error (#2628) Fixes #1225 Signed-off-by: Mark Hindess --- async_producer.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/async_producer.go b/async_producer.go index a5aebf15c..f629a6a2e 100644 --- a/async_producer.go +++ b/async_producer.go @@ -449,8 +449,10 @@ func (p *asyncProducer) dispatcher() { p.returnError(msg, ConfigurationError("Producing headers requires Kafka at least v0.11")) continue } - if msg.ByteSize(version) > p.conf.Producer.MaxMessageBytes { - p.returnError(msg, ErrMessageSizeTooLarge) + + size := msg.ByteSize(version) + if size > p.conf.Producer.MaxMessageBytes { + p.returnError(msg, ConfigurationError(fmt.Sprintf("Attempt to produce message larger than configured Producer.MaxMessageBytes: %d > %d", size, p.conf.Producer.MaxMessageBytes))) continue }