fix(librd): reject FetchInfo requests for unknown topics instead of panicking#21
Open
SAY-5 wants to merge 1 commit into
Open
fix(librd): reject FetchInfo requests for unknown topics instead of panicking#21SAY-5 wants to merge 1 commit into
SAY-5 wants to merge 1 commit into
Conversation
…anicking a.fetchInfo silently drops topics that the broker does not return metadata for, so a request like FetchInfo(["does-not-exist"]) used to flow through to admin.DescribeConfigs with an empty resources slice. librd's confluent-kafka-go DescribeConfigs implementation indexes into that slice and crashes with a runtime panic before any error can be surfaced (gmbyapa#19). Compare the size of fetchInfo's result against the requested topic list before building the resources slice. If anything is missing, collect the offending names and return them as a wrapped error so the caller sees a useful 'no metadata returned for topic(s) [...] (do they exist?)' message instead of a runtime crash. Closes gmbyapa#19 Signed-off-by: SAY-5 <SAY-5@users.noreply.github.com>
9a75ec1 to
9f48ee3
Compare
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
Fixes #19.
a.fetchInfosilently drops topics that the broker does not return metadata for, so a request likeFetchInfo(["does-not-exist"])flowed through toadmin.DescribeConfigswith an empty resources slice. librd's confluent-kafka-goDescribeConfigsimplementation indexes into that slice and crashes with a runtime panic before any error can be surfaced.Fix
Compare the size of
fetchInfo's result against the requested topic list before building the resources slice. If anything is missing, collect the offending names and return them as a wrapped error so the caller sees a usefulno metadata returned for topic(s) [...] (do they exist?)message instead of a runtime crash.Verification
Locally on macOS, go 1.26.2:
gofmt -s -l: cleango vet ./kafka/adaptors/librd/...: cleango build ./...: cleanThe librd adaptor wraps a CGO library that requires a live broker, so this package has no unit tests in the repo - the diff is a pure validation gate before the panicking call site, with no impact on the happy path.
Closes #19