danielgtaylor / danielgtaylor/huma
MimeTypeValidator.Validate never closes the file it opens
- Dominant language
- Go
- Stars
- 4.4k
- Forks
- 285
- Avg merge
- 40m
- Merged PRs (30d)
- 1
Description
`Validate()` opens the uploaded file to sniff the content type and never closes it. For any part above the adapter’s multipart memory threshold, that handle is a real file on disk, so the descriptor and its blocks stay held until the finalizer runs. `multipart.Form.RemoveAll()` only unlinks the temp file; it doesn’t close anything, so a service doing a lot of uploads can drift on file descriptors and ephemeral disk with nothing obvious pointing at the cause.
A deferred close in `Validate()` should cover that path. `readFile()` also opens the file before validation and returns without closing it when validation fails, so that path should be fixed too. Still present in v2.39.0.
Contributor guide
No contributing guide indexed for this repository
Research direction
Search the Go source for MimeTypeValidator.Validate and readFile, then trace how uploaded files are opened during validation. Confirm that both validation paths release opened files, including failures, and run the relevant existing Go tests or the package test suite to verify the upload behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- api
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100