-
-
Notifications
You must be signed in to change notification settings - Fork 176
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
refactor: split up huma.Register #705
refactor: split up huma.Register #705
Conversation
The diff is quite large, so I made an effort to clean up the branch history. I think it may be easiest to review this PR by traversing the commits. Every commit passes the tests ( Before I cleaned up the history I made a change, passed the tests, and later figured out that it broke the flow of logic for the |
@b-kamphorst this has been on my ToDo list for ages, so 1. Thank you so much for taking the time to do this and 2. Sorry I didn't get to it earlier! Looks like there is a small conflict I may be able to resolve, but I'll need to take some time and review. Originally I mashed much of this code together in an effort to keep it performant, so I will run some benchmarks too. Give me a couple days please - I do want to merge this cleanup! |
No worries, I appreciate your devotion to this wonderful project and I am glad that this may be of value. I'll rebase on Please take your time. Looking forward to your feedback. |
045f37e
to
e09d4a2
Compare
e09d4a2
to
1ce45cb
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #705 +/- ##
==========================================
+ Coverage 92.78% 92.90% +0.12%
==========================================
Files 22 22
Lines 4917 4964 +47
==========================================
+ Hits 4562 4612 +50
+ Misses 308 305 -3
Partials 47 47 ☔ 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.
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (2)
formdata.go:180
- The error message 'Failed to open file' is not very descriptive. Consider providing more details to help with debugging.
return FormFile{}, &ErrorDetail{Message: "Failed to open file", Location: location}
formdata.go:94
- The new behavior introduced in the Decode function should be covered by tests.
func (m *MultipartFormFiles[T]) Decode(opMediaType *MediaType) []error {
@b-kamphorst thanks for all this work! I've reviewed the code and it looks good. The one issue I found is that benchmarks showed an increase in dynamic memory allocations per request and I was able to |
That's nice! If you have any recommended sources on (that kind of) Go benchmarking then I would be interested. I'm a couple of months into the language. Glad to hear you valued the refactoring, happy to help! |
The current
huma.Register
function is 900+ lines of code and has up to 9 levels of nesting. While working on #694 I found it really hard to understand the logic. In my effort to understand the function, I performed several refactorings and I thought that you may appreciate them as well.Surely some parts are a matter of taste -- I don't mind changing them.
Looking forward to your thoughts.