Repository navigation
CON-623: franz outputs: send empty or null keys as nil keys - #5191
Merged
Merged
Conversation
Contributor
Connect docs checkThe docs build passed with this PR's generated docs. This PR changes 4 published pages (4 generated files: 4 changed, 0 added, 0 removed). Review the rendered pages, not only the Go strings. Per-file diffs and the rendered-HTML findings are in the job summary. Checked at efe0bbb. |
Leward
reviewed
Nov 12, 2026
Leward
left a comment
Contributor
There was a problem hiding this comment.
The fix itself is good, but I have concerns where a user would have a key that is legitimately the string "null". It's odd and unusual, but possible.
Leward
approved these changes
Nov 13, 2026
Leward
left a comment
Contributor
There was a problem hiding this comment.
Thanks for the follow-up. Looks good to me
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The franz-based outputs (
redpanda,kafka_franzand the components built on FranzWriter) send a key that resolves to an empty string or tonullas a null Kafka key, so those records are distributed across partitions.Why
A source record without a key reaches the output as an empty string, and a missing metadata entry or null Bloblang value renders as the bytes
null. franz-go hashes any non-nil key, so all such records were written to a single partition.How
nullwhen the key is interpolated, otherwise the key unchanged; applied in messageBatchToFranzRecords after key interpolation. A static key (no interpolation) such askey: "null"is kept as written.nullrendering is matched by value.keyfield description documents the null-key behaviour; the saramakafkaoutput keeps its previous text since it already drops empty keys and is out of scope.Testing
Test evidence
End to end: a source container, the connector built from this branch, and a checker for loss, duplicates, per-key order and content.
efe0bbb1fIntegration tests at
efe0bbb1f: go test -run Integration ./internal/impl/kafka/...: passed (kafka 127s, kafka/enterprise 10s), none skippedUpdated 2026-11-13.
Risks
Behaviour change: a key that interpolates to the empty string or to the literal string
nullis now sent as a null key instead of being hashed. An interpolated key whose value is the 4-byte string "null" (for example{"key":"null"}withkey: '${! json("key") }') is affected, since the interpolation renders it the same as a null value; a statickey: "null"is not. Both are documented in the field description and covered by TestFranzWriterKey.Jira: https://redpandadata.atlassian.net/browse/CON-623