-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix no-payload commit in consumer #833
Conversation
@@ -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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: because this is a C library, there is a difference between providing None
and not providing a parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh this is not None
being different from != None
and different from bool(optional)
stole me so much time in my life 😭
6ffb30a
to
4c21063
Compare
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.
4c21063
to
c8f3923
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got it, thanks for the fix :)
About this change - What it does
Prompted by a Sentry error, the issue is "triggered" by this line in the consumer manager.
The confluent-kafka
Consumer.commit
method can be called with no parameters, then the current partition assignment's offsets are used (see the documentation athttps://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.