Repository navigation
Conversation
A trailing comma or blank entry (e.g. "b1:9092,b2:9092,") produced a
('', 9092) host, which getaddrinfo resolves to localhost. The java client
trims entries and ignores empty ones; do the same.
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.
collect_hostsdoesn't skip empty entries, so a trailing comma or a blank item inbootstrap_serversadds a hidden bootstrap broker at localhost:9092:This is easy to hit when the value is built from env vars or templates. Depending on the setup, you get connection errors to localhost in the logs, or the client bootstraps against a local broker nobody configured. The Java client trims entries and ignores empty ones (
ClientUtils.parseAndValidateAddresses).The fix strips each entry and skips it if it's empty after removing the
PROTOCOL://prefix, so a barePLAINTEXT://is skipped too.Tests: added
test_collect_hosts__ignores_empty_entrieswith trailing comma, double comma, whitespace-only, bare protocol and list inputs. It fails before the change and passes after. The unit suite passes:pytest test --ignore=test/integrationgives 2764 passed, 1 skipped.I left the all-empty case (
bootstrap_servers=",") alone. It now returns no hosts instead of[('', 9092)]. Raising there like Java does seemed like a separate decision; happy to add it if you want.I used Claude Code to help find and test this, and I reviewed the change myself.