Repository navigation
fix(stream): avoid EOF when decoding ext into pointer/interface destinations - #148
Merged
Merged
Conversation
…ations When a custom stream ext decoder was registered, tryExtDecode consumed the ext frame and then fell back to kind-based decoding for pointer and interface destinations, which read the frame again and failed with EOF. Fill pointer/interface destinations directly from the decoded value and report an error when a consumed frame is not claimed by any decoder. Complex destinations are left to the kind switch, which decodes their dedicated ext frame itself.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #148 +/- ##
==========================================
+ Coverage 92.56% 92.78% +0.21%
==========================================
Files 75 75
Lines 7157 7189 +32
==========================================
+ Hits 6625 6670 +45
+ Misses 330 319 -11
+ Partials 202 200 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Merged
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
UnmarshalReadwhen a custom stream ext decoder is registeredBackground
#117 (v3.2.2) added
tryExtDecodebefore the kind switch. Once a custom stream ext coder is registered alongside the built-in time decoder, the ext frame is consumed before the destination type is checked. On a mismatch the decoder fell back to kind-based decoding, which read the frame again and hit EOF. Affected destinations includeinterface{},*T,map[string]interface{},[]interface{}, pointer struct fields, and complex types. This applies to both custom ext and time values. The buffer decoder (Unmarshal) and v2 are not affected.Changes
UnmarshalUnmarshalReadwithUnmarshalacross custom ext, time, and complex destinationsTestDecodeUnhashableExtMapKeyTest Plan
go vet ./...andgo test -race ./...Notes