fix(go): correct buffer size for CreateUser and UpdatePermissions serialization#3097
Open
atharvalade wants to merge 1 commit intoapache:masterfrom
Open
fix(go): correct buffer size for CreateUser and UpdatePermissions serialization#3097atharvalade wants to merge 1 commit intoapache:masterfrom
atharvalade wants to merge 1 commit intoapache:masterfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3097 +/- ##
=========================================
Coverage 72.71% 72.72%
Complexity 943 943
=========================================
Files 1117 1117
Lines 96285 96285
Branches 73485 73485
=========================================
+ Hits 70014 70020 +6
+ Misses 23725 23719 -6
Partials 2546 2546
🚀 New features to boost your workflow:
|
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 #2981
Rationale
The Go SDK's
CreateUserandUpdatePermissionscommands had incorrect buffer size calculations for thehas_permissionsflag byte, causing a 1-byte over-allocation inCreateUser(non-nil path) and an index-out-of-bounds panic inUpdatePermissions(nil path).What changed?
Both
CreateUser.MarshalBinary()andUpdatePermissions.MarshalBinary()double-counted the 1-bytehas_permissionsflag in the non-nil branch, whileUpdatePermissionsomitted it entirely from the base allocation (causing a panic when permissions were nil).The fix accounts for the
has_permissionsbyte exactly once: inCreateUserit is part of the base capacity4, and inUpdatePermissionsit is now added to the baselength. The+1was removed from the non-nil branch in both methods. Unit tests were added for all four cases (nil/non-nil x CreateUser/UpdatePermissions).Local Execution
go test ./...all pass;gofmtclean;go vetclean)AI Usage