Repository navigation
fix: support binary Kafka headers without decoding errors - #2459
Bazarovinc wants to merge 16 commits into
Conversation
|
@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. |
8585bf6 to
d0ee2c6
Compare
…aracters to avoid errors
d0ee2c6 to
b326e40
Compare
…e unused _HeadersInput
…reaking other brokers)
|
@Bazarovinc @Sehat1137 @draincoder Any updates on this PR? We are currently stumbling into the same original issue and needed to implement a workaround for it. Would be nice to have this included in a near future release, thanks for an update! :) |
708e64f to
79ed88c
Compare
|
@draincoder @fstermann Following up on the binary-header/test-coverage request and the status question: the PR has been updated and is ready for another review. Both AIOKafka and Confluent now accept Coverage includes single/batch binary publishing and Response forwarding, real-producer encoding, native Confluent sequence normalization, raw-header access, and 44 parser cases. The focused local affected-scenario run passed 273 tests with two existing expected failures for #2513; real Kafka validation passed for both drivers in single and batch mode. The full CI matrix has now passed on |
|
@IvanKirpichnikov Addressed all 10 comments from your latest review in cf7042938.
All existing header-value cases are retained. The focused local suite passes all 63 cases. Mypy (1,913 files), Ruff, the remaining static analyzers, and file-level pre-commit checks passed; codespell excluded the generated CI is also green for this commit: Run all tests, Run linters, and CodeQL. Ready for another review. |
Summary
Kafka headers containing arbitrary bytes raise
UnicodeDecodeErrorduring single-message and batch consumption. Publishing binary headers also fails because producers call.encode()on every value.Fixes #2458. Fixes #2214.
Support both AIOKafka and Confluent, including publishers, responses, batches, FastAPI publishers and in-memory TestBrokers. Keep header decoding compatible with existing text consumers. Normalize Confluent header sequences before calling the native client. Review regressions cover each reserved header independently, especially reply_to without content-type, nullable/empty/malformed values, and first-message metadata in a batch.
Evidence
c363b80a0(2026-10-13), all four parser regression tests fail withUnicodeDecodeError. Restoring the old producer conversions also fails the binary publishing regressions.graphify-out/directory in addition to the generated documentation site.Type of change
Checklist
just test-coveragematrix (left to CI)Merge Danger
Door: two-way; revert the code to roll back.
Blast Radius: Kafka header handling in the AIOKafka and Confluent integrations. Existing decoded string headers remain available. Null values are omitted from the decoded view and retained in raw headers. Duplicate header entries remain accessible through the native message's header sequence.