fix: add Unwrap() to DescribeConfigError and AlterConfigError#3487
Open
ShinThirty wants to merge 1 commit intoIBM:mainfrom
Open
fix: add Unwrap() to DescribeConfigError and AlterConfigError#3487ShinThirty wants to merge 1 commit intoIBM:mainfrom
ShinThirty wants to merge 1 commit intoIBM:mainfrom
Conversation
fec5deb to
ae6ae04
Compare
TopicError and TopicPartitionError implement Unwrap() returning their KError field, enabling errors.Is/As to traverse the error chain. However, DescribeConfigError and AlterConfigError have the same structure (Err KError + ErrMsg) but were missing Unwrap(), making errors.Is/As unable to match the underlying KError. This adds the missing Unwrap() methods for consistency, allowing callers to use errors.Is(err, sarama.ErrInvalidConfig) instead of type-asserting to extract the error code. Signed-off-by: Lingnan Liu <xmxu00@gmail.com>
ae6ae04 to
5511bbc
Compare
puellanivis
reviewed
Apr 5, 2026
Collaborator
puellanivis
left a comment
There was a problem hiding this comment.
🤷♀️ I see nothing wrong with the code. The only concern here is if this is desired behavior.
Author
|
I don't think we documented the expected behavior of the errors? Also this is a pure addition so it is backward compatible. |
Collaborator
|
Correct. My point is more: as a collaborator who does code reviews, nothing is wrong with the code. My point is that it’s on the maintainers to decide if they’re good with the behavior change, which I agree is an improvement. |
puellanivis
approved these changes
Apr 7, 2026
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.
Summary
TopicErrorandTopicPartitionErrorimplementUnwrap()returning theirKErrorfield, enablingerrors.Is/errors.Asto traverse the error chain. However,DescribeConfigErrorandAlterConfigErrorhave the same structure (Err KError+ErrMsg) but were missingUnwrap(), makingerrors.Is/errors.Asunable to match the underlyingKError.This adds the missing
Unwrap()methods for consistency, allowing callers to useerrors.Is(err, sarama.ErrInvalidConfig)instead of type-asserting to extract the error code.Changes
Unwrap() errorto*DescribeConfigError(describe_configs_response.go)Unwrap() errorto*AlterConfigError(alter_configs_response.go)TestTopicErrorpatternTest plan
go test -run 'TestDescribeConfigError|TestAlterConfigError|TestTopicError'— all passgo vet ./...— clean