Skip to content

fix(librd): reject FetchInfo requests for unknown topics instead of panicking#21

Open
SAY-5 wants to merge 1 commit into
gmbyapa:masterfrom
SAY-5:fix/fetchinfo-missing-topics-19
Open

fix(librd): reject FetchInfo requests for unknown topics instead of panicking#21
SAY-5 wants to merge 1 commit into
gmbyapa:masterfrom
SAY-5:fix/fetchinfo-missing-topics-19

Conversation

@SAY-5

@SAY-5 SAY-5 commented Apr 21, 2026

Copy link
Copy Markdown

What

Fixes #19.

a.fetchInfo silently drops topics that the broker does not return metadata for, so a request like FetchInfo(["does-not-exist"]) flowed 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.

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 useful no 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: clean
  • go vet ./kafka/adaptors/librd/...: clean
  • go build ./...: clean

The 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

…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>
@SAY-5 SAY-5 force-pushed the fix/fetchinfo-missing-topics-19 branch from 9a75ec1 to 9f48ee3 Compare May 31, 2026 02:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing validation for fetchInfo response

1 participant