From c8f3923886fcae84daa0c0840abb9297d7cea93d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1ty=C3=A1s=20Kuti?= Date: Tue, 5 Mar 2024 12:43:00 +0100 Subject: [PATCH] Fix no-payload commit in consumer The confluent-kafka `Consumer.commit` method can be called with no parameters, then the current partition assignment's offsets are used (see the documentation at https://docs.confluent.io/platform/current/clients/confluent-kafka-python/html/index.html#confluent_kafka.Consumer.commit). The previous behaviour was erroneous, raising a `TypeError`, thus an HTTP 500 when in the REST proxy's consumer manager a commit is performed with an empty payload. --- karapace/kafka/consumer.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/karapace/kafka/consumer.py b/karapace/kafka/consumer.py index 2899820cd..762295d3d 100644 --- a/karapace/kafka/consumer.py +++ b/karapace/kafka/consumer.py @@ -86,7 +86,10 @@ def commit( # type: ignore[override] if message is not None: return super().commit(message=message, asynchronous=False) - return super().commit(offsets=offsets, asynchronous=False) + if offsets is not None: + return super().commit(offsets=offsets, asynchronous=False) + + return super().commit(asynchronous=False) except KafkaException as exc: raise_from_kafkaexception(exc)