Skip to content

Commit

Permalink
Fix no-payload commit in consumer
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Mátyás Kuti committed Mar 5, 2024
1 parent 4ae29e6 commit c8f3923
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion karapace/kafka/consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit c8f3923

Please sign in to comment.