-
-
Notifications
You must be signed in to change notification settings - Fork 234
fix: expose metadata of decoded multipart form files #466
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
WalkthroughThe recent changes introduce Changes
Assessment against linked issues
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #466 +/- ##
==========================================
+ Coverage 92.84% 92.85% +0.01%
==========================================
Files 22 22
Lines 3761 3767 +6
==========================================
+ Hits 3492 3498 +6
Misses 225 225
Partials 44 44 ☔ View full report in Codecov by Sentry. |
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
Outside diff range and nitpick comments (3)
huma_test.go (3)
Line range hint
779-796: Enhance the OpenAPI generation tests.Consider adding more comprehensive assertions to ensure that the OpenAPI specifications are not only generated but are accurate and complete. This could involve checking for the presence of specific paths, operations, and responses in the generated documentation.
Line range hint
779-796: Improve error handling tests.It would be beneficial to expand the error handling tests to cover more scenarios, particularly those involving nested structures and complex data types. This would help ensure that the library robustly handles errors in a variety of real-world applications.
Line range hint
779-796: Optimize benchmark tests.Consider refining the benchmark tests to provide more granular insights into performance differences. This could involve separating setup and teardown stages, using more iterations, and possibly comparing more variants of handler function definitions.
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- formdata.go (2 hunks)
- huma_test.go (2 hunks)
Additional comments not posted (4)
formdata.go (2)
17-18: The addition ofSizeandFilenamefields to theFormFilestruct aligns well with the PR objectives and enhances the struct's functionality by exposing necessary file metadata.
99-105: The updates to thereadFilemethod to populate theSizeandFilenamefields in theFormFilestruct are correctly implemented. This ensures that the file metadata is properly set when a file is read, aligning with the PR's objectives.huma_test.go (2)
Line range hint
779-796: Ensure proper handling of file metadata in multipart form data.The changes correctly implement the extraction and assertion of file metadata (
FilenameandSize) as described in the PR objectives. This is crucial for the functionality of handling multipart form data more effectively.
Line range hint
779-796: Verify the handling of multiple file uploads.This script checks if the filenames are correctly formatted and assigned based on the index, which is critical for ensuring that files are not only uploaded but also correctly identified and processed.
Verification successful
The handling of multiple file uploads is correctly implemented in the
TestFeaturesfunction. The assertions for filenames, content types, and sizes are present and correctly formatted.
- The filenames are correctly assigned using
fmt.Sprintf("greetings_%d.txt", i+1).- The content types and sizes are verified for each file in the
Greetingsarray.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the handling of multiple file uploads, especially the correct assignment of filenames and sizes. # Test: Search for the function usage. Expect: Only occurances of the new signature. rg --type go $'assert.Equal(t, fmt.Sprintf("greetings_%d.txt", i+1), fileData.Greetings[i].Filename)'Length of output: 102
Script:
#!/bin/bash # Description: Verify the handling of multiple file uploads by checking related assertions in the test function. # Search for assertions related to file uploads in the test function. rg --type go 'assert.Equal(t, "text/plain", fileData.Greetings[i].ContentType)' -A 5Length of output: 86
Script:
#!/bin/bash # Description: Verify the handling of multiple file uploads by reviewing the content of the `TestFeatures` function. # Search for the `TestFeatures` function definition and its content. rg --type go 'func TestFeatures' -A 50Length of output: 2404
Script:
#!/bin/bash # Description: Verify the handling of multiple file uploads by reviewing the complete content of the `TestFeatures` function. # Search for the `TestFeatures` function definition and its content with a larger context. rg --type go 'func TestFeatures' -A 200Length of output: 8486
Script:
#!/bin/bash # Description: Verify the handling of multiple file uploads by reviewing the complete content of the `TestFeatures` function. # Search for the `TestFeatures` function definition and its content with an even larger context. rg --type go 'func TestFeatures' -A 400Length of output: 19624
Script:
#!/bin/bash # Description: Verify the handling of multiple file uploads by reviewing the complete content of the `TestFeatures` function. # Search for the `TestFeatures` function definition and its content with an even larger context. rg --type go 'func TestFeatures' -A 600Length of output: 28294
Script:
#!/bin/bash # Description: Verify the handling of multiple file uploads by reviewing the complete content of the `TestFeatures` function. # Search for the `TestFeatures` function definition and its content with an even larger context. rg --type go 'func TestFeatures' -A 800Length of output: 38005
danielgtaylor
left a comment
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.
LGTM, thank you! 👍
fixes #465
Summary by CodeRabbit
New Features
Tests