-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix(net/ghttp): panic when post empty string parameter to *ghttp.UploadFile
#4226
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
base: master
Are you sure you want to change the base?
Conversation
|
related #4203 |
|
@gqcn 过不了单测 |
@gqcn Can't pass the single test |
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.
Pull Request Overview
This PR fixes a panic that occurs when posting an empty string parameter to *ghttp.UploadFile by improving handling of empty values in the type conversion system. The fix addresses issue #4193 where empty strings were causing conversion failures that led to panics.
- Adds early return handling for empty strings in float conversion functions
- Updates error handling in struct conversion to properly propagate errors instead of suppressing them
- Modifies map conversion logic to return empty maps when mustMapReturn is true for empty inputs
- Changes default error handling behavior in Scan function to fail fast instead of continuing on errors
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| util/gconv/internal/converter/converter_struct.go | Updates error message format and removes fallback conversion that was masking errors |
| util/gconv/internal/converter/converter_map.go | Adds handling for empty strings/bytes to return empty maps when required |
| util/gconv/internal/converter/converter_float.go | Adds empty string checks to return 0 instead of attempting invalid parsing |
| util/gconv/internal/converter/converter_convert.go | Minor variable declaration style change and comment correction |
| util/gconv/gconv_scan.go | Changes default ContinueOnError from true to false for better error visibility |
| net/ghttp/ghttp_z_unit_issue_test.go | Adds test case for the fixed issue and corrects indentation |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
fixed #4193