Skip to content
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

Merged
merged 1 commit into from
Mar 5, 2024

Conversation

matyaskuti
Copy link
Contributor

@matyaskuti matyaskuti commented Mar 5, 2024

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 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.

@@ -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)
Copy link
Contributor Author

@matyaskuti matyaskuti Mar 5, 2024

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.

Copy link
Contributor

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 😭

@matyaskuti matyaskuti force-pushed the matyaskuti/fix_rest_proxy_commit_empty_payload branch 2 times, most recently from 6ffb30a to 4c21063 Compare March 5, 2024 12:22
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.
@matyaskuti matyaskuti force-pushed the matyaskuti/fix_rest_proxy_commit_empty_payload branch from 4c21063 to c8f3923 Compare March 5, 2024 12:46
@matyaskuti matyaskuti marked this pull request as ready for review March 5, 2024 13:37
@matyaskuti matyaskuti requested review from a team as code owners March 5, 2024 13:37
Copy link
Contributor

@eliax1996 eliax1996 left a 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 :)

@eliax1996 eliax1996 merged commit af21074 into main Mar 5, 2024
8 checks passed
@eliax1996 eliax1996 deleted the matyaskuti/fix_rest_proxy_commit_empty_payload branch March 5, 2024 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants