Skip to content

Fix panic when sending an empty file field in a form #785

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Supet1337
Copy link

Fix panic on empty file field in RawBody

Problem

When an empty file field is submitted in a form (multipart/form-data), form.Value contains an empty string (""), but form.File is missing. This leads to a panic with the error: unsupported param type huma.FormFile

Solution

Now, before accessing form.Value[p.Name], we check if the value is an empty string and handle it correctly. If the parameter is required and not a valid file, a proper validation error is returned instead of causing a panic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant