fix(go): return error instead of panic on S2 decode failure#3166
Open
atharvalade wants to merge 3 commits intoapache:masterfrom
Open
fix(go): return error instead of panic on S2 decode failure#3166atharvalade wants to merge 3 commits intoapache:masterfrom
atharvalade wants to merge 3 commits intoapache:masterfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3166 +/- ##
============================================
- Coverage 74.10% 72.80% -1.30%
Complexity 943 943
============================================
Files 1159 1117 -42
Lines 102033 96111 -5922
Branches 79083 73289 -5794
============================================
- Hits 75607 69976 -5631
+ Misses 23765 23591 -174
+ Partials 2661 2544 -117
🚀 New features to boost your workflow:
|
chengxilo
reviewed
Apr 30, 2026
| payloadSlice, err = s2.Decode(nil, payloadSlice) | ||
| if err != nil { | ||
| panic("iggy: failed to decode s2 payload: " + err.Error()) | ||
| return nil, fmt.Errorf("iggy: failed to decode s2 payload: %w", err) |
Contributor
There was a problem hiding this comment.
nit
Suggested change
| return nil, fmt.Errorf("iggy: failed to decode s2 payload: %w", err) | |
| return nil, fmt.Errorf("failed to decode s2 payload: %w", err) |
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.
Which issue does this PR close?
Closes #3129
Rationale
Library code should never panic on bad server data — a truncated or corrupt S2-compressed message currently crashes the entire Go client process.
What changed?
DeserializeFetchMessagesResponsecalledpanic()whens2.Decodefailed on a malformed compressed payload. Callers had no way to recover.Replaced
panic(...)withreturn nil, fmt.Errorf(...)so the error propagates through the existingerrorreturn value. Added unit tests covering the malformed S2 path, the no-compression path, and the empty-payload path.Local Execution
AI Usage
go test,go vet, and CI lint scripts locally; all pass