-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
🐛 Fix validation error when File is declared after Form parameter
#11194
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 validation error when File is declared after Form parameter
#11194
Conversation
1763ed4 to
dcd2e69
Compare
7e97f62 to
0a1e865
Compare
|
Thank you for the feed back. I pushed force with your suggested changes. Let me know if anything else can be improved. |
YuriiMotov
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.
The solution works.
Tests cover the issue. Tests fail before changes and pass after
|
I am wondering if this PR has been forgotten? I am not that familiar with the workflow in this repository, so excuse me if these things just take time or if this has low priority and there have been more important things to spend your time on. However, I was affected by #9116 which led me to this PR, and since it has some approvals and it hasn't been touched in 9 months, I thought it would be ok to "bump" it. |
|
Hey what about this pr? At least there should be a better error message. Wasted my time only for finding this. |
This comment was marked as resolved.
This comment was marked as resolved.
0a1e865 to
4b6e747
Compare
This comment was marked as resolved.
This comment was marked as resolved.
577dce8 to
150fb07
Compare
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
50b9f22 to
e34c53c
Compare
…t of a multipart/form-data request body The HTTP specification for multipart/form-data, defined in RFC 7578, allows both form data and uploaded files in a single request. It does not require files to be before or after form fields. As such, no specific care is to be given to the first field. References: - [RFC 7578](https://datatracker.ietf.org/doc/html/rfc7578) - [FastAPI issue 9116](fastapi#9116) Close fastapi#9116
bb07937 to
6e0abe9
Compare
|
@YuriiMotov here you go. |
YuriiMotov
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!
File is declared after Form parameter
tiangolo
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.
Great, thank you! 🚀 🙌
This PR updates the fix (6185a92) from @jsg921019 so that tests pass with the latest FastAPI code (0.110.0).
It also adds a test to cover the case with multiple files, and another to ensure the order of parameters in an endpoint definition does not affect the way FastAPI handles the request.
Problem
When declaring an endpoint which accepts a
Filebut also aFormparameter, theFileparameter must be declared first or the endpoint would respond with error 422.Context