atharvalade opened a new pull request, #3097:
URL: https://github.com/apache/iggy/pull/3097

   ## Which issue does this PR close?
   
   Closes #2981
   
   ## Rationale
   
   The Go SDK's `CreateUser` and `UpdatePermissions` commands had incorrect 
buffer size calculations for the `has_permissions` flag byte, causing a 1-byte 
over-allocation in `CreateUser` (non-nil path) and an index-out-of-bounds panic 
in `UpdatePermissions` (nil path).
   
   ## What changed?
   
   Both `CreateUser.MarshalBinary()` and `UpdatePermissions.MarshalBinary()` 
double-counted the 1-byte `has_permissions` flag in the non-nil branch, while 
`UpdatePermissions` omitted it entirely from the base allocation (causing a 
panic when permissions were nil).
   
   The fix accounts for the `has_permissions` byte exactly once: in 
`CreateUser` it is part of the base capacity `4`, and in `UpdatePermissions` it 
is now added to the base `length`. The `+1` was 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
   
   - Passed
   - Pre-commit hooks ran (trailing-whitespace, trailing-newline, 
license-headers all pass; `go test ./...` all pass; `gofmt` clean; `go vet` 
clean)
   
   ## AI Usage
   
   1. Opus 4.6
   2. Minimal AI used
   3. Yes, all code can be explained


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to