Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

🐛 Fix validation error whenFile is declared afterForm parameter#11194

Merged
tiangolo merged 4 commits intofastapi:masterfrom
thomasleveil:fix-9116-form-and-file-order
Sep 20, 2025
Merged

🐛 Fix validation error whenFile is declared afterForm parameter#11194
tiangolo merged 4 commits intofastapi:masterfrom
thomasleveil:fix-9116-form-and-file-order

Conversation

@thomasleveil
Copy link
Contributor

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 aFile but also aForm parameter, theFile parameter must be declared first or the endpoint would respond with error 422.

Context

@thomasleveilthomasleveilforce-pushed thefix-9116-form-and-file-order branch from1763ed4 todcd2e69CompareFebruary 25, 2024 15:11
YuriiMotov

This comment was marked as outdated.

@thomasleveilthomasleveilforce-pushed thefix-9116-form-and-file-order branch from7e97f62 to0a1e865CompareFebruary 25, 2024 16:07
@thomasleveil
Copy link
ContributorAuthor

Thank you for the feed back. I pushed force with your suggested changes. Let me know if anything else can be improved.

@thomasleveilthomasleveil changed the titleFix #9116 form and file order🐛 Fix #9116 form and file orderFeb 25, 2024
@thomasleveilthomasleveil changed the title🐛 Fix #9116 form and file order🐛 Fix #9116 Form and File parameters order should not matterFeb 25, 2024
Copy link
Member

@YuriiMotovYuriiMotov left a 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

@cfreksen
Copy link

cfreksen commentedNov 22, 2024
edited
Loading

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.

Danstiv, nesangcode, synodriver, markoglasgow, eugene-babichenko, and alxping reacted with thumbs up emoji

@carl-sauter
Copy link

Hey what about this pr? At least there should be a better error message. Wasted my time only for finding this.

@YuriiMotovYuriiMotov self-requested a reviewJune 21, 2025 17:05
@YuriiMotov

This comment was marked as resolved.

@thomasleveilthomasleveilforce-pushed thefix-9116-form-and-file-order branch from0a1e865 to4b6e747CompareJune 22, 2025 17:21
@thomasleveil

This comment was marked as resolved.

@thomasleveilthomasleveilforce-pushed thefix-9116-form-and-file-order branch from577dce8 to150fb07CompareJune 22, 2025 17:27
@YuriiMotov

This comment was marked as resolved.

@thomasleveil

This comment was marked as resolved.

@YuriiMotov

This comment was marked as resolved.

@thomasleveilthomasleveilforce-pushed thefix-9116-form-and-file-order branch 2 times, most recently from50b9f22 toe34c53cCompareJune 23, 2025 12:32
…t of a multipart/form-data request bodyThe 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)Closefastapi#9116
@thomasleveilthomasleveilforce-pushed thefix-9116-form-and-file-order branch frombb07937 to6e0abe9CompareJune 23, 2025 12:55
@thomasleveil
Copy link
ContributorAuthor

@YuriiMotov here you go.

Copy link
Member

@YuriiMotovYuriiMotov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

LGTM!

@YuriiMotovYuriiMotov changed the title🐛 Fix #9116 Form and File parameters order should not matter🐛 Fix validation error whenFile is declared afterForm parameterJun 23, 2025
Copy link
Member

@tiangolotiangolo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Great, thank you! 🚀 🙌

@tiangolotiangolo merged commit44fc676 intofastapi:masterSep 20, 2025
29 checks passed
@thomasleveilthomasleveil deleted the fix-9116-form-and-file-order branchSeptember 26, 2025 08:08
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@tiangolotiangolotiangolo approved these changes

@YuriiMotovYuriiMotovYuriiMotov approved these changes

+1 more reviewer

@yezz123yezz123yezz123 approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

bugSomething isn't workingp2

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

6 participants

@thomasleveil@cfreksen@carl-sauter@YuriiMotov@tiangolo@yezz123

Comments


[8]ページ先頭

©2009-2026 Movatter.jp