Skip to content
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

Fix File field when it receives an empty value #301

Merged
merged 3 commits into from Mar 18, 2024

Conversation

uncle-lv
Copy link
Contributor

When we don't select a file, swagger send an empty value like this:

POST http://localhost:5000/images HTTP/1.1
Content-Type: multipart/form-data; boundary=---------------------------70636434840698183742419445910

-----------------------------70636434840698183742419445910
Content-Disposition: form-data; name="image"


-----------------------------70636434840698183742419445910--

Then the value of File field(named image above) is an empty string, and a ValidationError("Not a valid file.") occurs.
But in fact it's missing.

@uncle-lv
Copy link
Contributor Author

This bug is found here.

@sloria
Copy link
Member

sloria commented Mar 18, 2024

thanks for fixing these! I'll merge and release these File field fixes when i get some time today

@sloria sloria enabled auto-merge (squash) March 18, 2024 19:03
@sloria sloria merged commit 4785db3 into marshmallow-code:dev Mar 18, 2024
8 checks passed
@raulblanxart
Copy link

raulblanxart commented Mar 19, 2024

Hi, thanks for the fast fix of this issue.
I'm triying to check the fix, but now the error comes when add a file, i had the same 422 error

thanks.

@uncle-lv
Copy link
Contributor Author

uncle-lv commented Mar 19, 2024

Hi, thanks for the fast fix of this issue. I'm triying to check the fix, but i can't use the new code, whuen I install apiflask i think that not dowload the new version.

When will be available the new version?

thanks.

A new version of apiflask hasn't been released. And I don't have permission to do it.
@greyli usually releases new versions on weekends.

For this bug, you can just upgrade your flask-marshmallow after it's new version is released.

@raulblanxart
Copy link

Yes sorry, was mi mistake, I didn't read the error, the plobelms comes for the file extension.

Yes now all it's working fine.

Thans!

@uncle-lv uncle-lv changed the title fix(fields.py): fix File field bug when get an empty value Fix File field when it receives an empty value Mar 19, 2024
@uncle-lv uncle-lv deleted the fix-empty-value branch March 21, 2024 15:48
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.

None yet

3 participants