From 30e18771c4a28b98ddac4565080f35f352f91ee3 Mon Sep 17 00:00:00 2001 From: Robin Tang Date: Tue, 7 May 2024 17:28:42 -0700 Subject: [PATCH] Remove TODO. (#376) --- lib/kafkalib/errors.go | 26 ++------------------------ lib/kafkalib/errors_test.go | 4 ---- 2 files changed, 2 insertions(+), 28 deletions(-) diff --git a/lib/kafkalib/errors.go b/lib/kafkalib/errors.go index 10d06771..a4592497 100644 --- a/lib/kafkalib/errors.go +++ b/lib/kafkalib/errors.go @@ -2,37 +2,15 @@ package kafkalib import ( "errors" - "log/slog" - "strings" - "github.com/segmentio/kafka-go" ) func isExceedMaxMessageBytesErr(err error) bool { - if err == nil { - return false - } - - if errors.Is(err, kafka.MessageSizeTooLarge) { - return true - } - - if strings.Contains(err.Error(), - "Message Size Too Large: the server has a configurable maximum message size to avoid unbounded memory allocation and the client attempted to produce a message larger than this maximum") { - // TODO: Remove this if we don't see it in the logs - slog.Error("Matched 'Message Size Too Large' error but not kafka.MessageSizeTooLarge") - return true - } - - return false + return err != nil && errors.Is(err, kafka.MessageSizeTooLarge) } // isRetryableError - returns true if the error is retryable // If it's retryable, you need to reload the Kafka client. func isRetryableError(err error) bool { - if err == nil { - return false - } - - return errors.Is(err, kafka.TopicAuthorizationFailed) + return err != nil && errors.Is(err, kafka.TopicAuthorizationFailed) } diff --git a/lib/kafkalib/errors_test.go b/lib/kafkalib/errors_test.go index c9291930..41faae07 100644 --- a/lib/kafkalib/errors_test.go +++ b/lib/kafkalib/errors_test.go @@ -22,10 +22,6 @@ func TestIsExceedMaxMessageBytesErr(t *testing.T) { { err: nil, }, - { - err: fmt.Errorf("Message Size Too Large: the server has a configurable maximum message size to avoid unbounded memory allocation and the client attempted to produce a message larger than this maximum, bytes: 1223213213"), - expected: true, - }, { err: kafka.TopicAuthorizationFailed, expected: false,