-
Notifications
You must be signed in to change notification settings - Fork 288
Fix: Handle non-UTF-8 headers in Kafka/Confluent message parsing #2459
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
base: main
Are you sure you want to change the base?
Fix: Handle non-UTF-8 headers in Kafka/Confluent message parsing #2459
Conversation
Nikita Veselenko seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
@Bazarovinc Please look at this #2214 issue as well and add comprehensive tests. |
@draincoder Here’s a preliminary implementation for handling Kafka message headers. Please review and let me know if this approach looks good or if any adjustments are needed. |
headers.get("reply_to"), | ||
headers.get("content-type"), | ||
headers.get("correlation_id"), |
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.
what does headers.get
return? Can you show example or write type?
reply_to=headers.get("reply_to", ""), | ||
content_type=headers.get("content-type"), | ||
reply_to=headers.get("reply_to").decode() | ||
if "content-type" in headers |
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.
content-type -> reply_to
reply_to=headers.get("reply_to").decode() | ||
if "content-type" in headers | ||
else None, | ||
content_type=headers.get("content-type").decode() | ||
if "content-type" in headers | ||
else None, | ||
message_id=f"{first.offset()}-{last.offset()}-{first_timestamp}", | ||
correlation_id=headers.get("correlation_id"), | ||
correlation_id=headers.get("correlation_id").decode() | ||
if "correlation_id" in headers | ||
else None, |
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.
What do u this about this way for better readable:
reply_to=headers.get("reply_to", b"").decode() or None
content_type=headers.get("content-type", b"").decode() or None
correlation_id=headers.get("correlation_id", b"").decode() or None
This PR addresses the UnicodeDecodeError that occurred when processing Kafka messages containing headers with non-UTF-8 byte sequences
Fixes #2458, FIxes #2214
Type of change
Checklist
just lint
shows no errors)just test-coverage
just static-analysis