-
Notifications
You must be signed in to change notification settings - Fork 4k
fix: use ParseUint in raw-bytes to support 0–255 #25134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
📝 WalkthroughWalkthroughAdjusted per-byte input parsing in the debug client from signed to unsigned integers. The code now uses ParseUint for 8-bit values and casts to byte accordingly, shifting accepted input range from -128..127 to 0..255. Error handling and surrounding logic/output remain unchanged. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes ✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
client/debug/main.go (1)
307-319
: Harden whitespace handling and error messages; preallocate capacityCurrent splitting by " " can produce empty tokens on extra spaces (e.g., "[10 21]") leading to parse errors. Use strings.Fields to normalize whitespace, TrimSpace the input, and preallocate the byte slice. Also add token context to the error.
- stringBytes := args[0] - stringBytes = strings.Trim(stringBytes, "[") - stringBytes = strings.Trim(stringBytes, "]") - spl := strings.Split(stringBytes, " ") - - byteArray := []byte{} - for _, s := range spl { - u, err := strconv.ParseUint(s, 10, 8) - if err != nil { - return err - } - byteArray = append(byteArray, byte(u)) - } + raw := strings.TrimSpace(args[0]) + raw = strings.TrimPrefix(raw, "[") + raw = strings.TrimSuffix(raw, "]") + tokens := strings.Fields(raw) + + byteArray := make([]byte, 0, len(tokens)) + for _, s := range tokens { + u, err := strconv.ParseUint(s, 10, 8) + if err != nil { + return fmt.Errorf("invalid byte %q: %w", s, err) + } + byteArray = append(byteArray, byte(u)) + }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Knowledge Base: Disabled due to Reviews > Disable Knowledge Base setting
📒 Files selected for processing (1)
client/debug/main.go
(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
client/debug/main.go (1)
math/uint.go (1)
ParseUint
(240-246)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Summary
🔇 Additional comments (1)
client/debug/main.go (1)
314-318
: Correctly switches to unsigned parsing for 0–255 rangeUsing strconv.ParseUint(..., 10, 8) and casting to byte is the right approach. It preserves 0–127 behavior and properly supports 128–255 while rejecting negatives as intended.
can you test this change? |
Done |
fixed lint |
Replace strconv.ParseInt(..., 10, 8) with strconv.ParseUint(..., 10, 8) and cast to byte so inputs in the full 0–255 range (including 255) are parsed correctly. Behavior for 0–127 remains unchanged. No other files touched.
Summary by CodeRabbit
New Features
Bug Fixes