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 body parsing #918

Merged
merged 2 commits into from Feb 4, 2020
Merged

Fix body parsing #918

merged 2 commits into from Feb 4, 2020

Conversation

dmontagu
Copy link
Collaborator

Closes #914

I believe this is the "correct" way to fix this issue, as the provided body could be invalid in a number of ways, and this should handle anything that json could get parsed into. (The error message also seems appropriate to me even for malformed bodies.)

There was actually already a test for this, but it only checked for a (malformed) body of None, not [], so it was easy to add a test case as another parametric case.

@@ -685,6 +678,16 @@ def request_params_to_args(
return values, errors


def get_missing_field_error(field_alias: str) -> ErrorWrapper:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Since this error is now used in two places, I added a utility function to generate it.

@codecov
Copy link

codecov bot commented Jan 25, 2020

Codecov Report

Merging #918 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #918   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files         293    293           
  Lines        7692   7699    +7     
=====================================
+ Hits         7692   7699    +7
Impacted Files Coverage Δ
...rial/test_body_multiple_params/test_tutorial003.py 100% <ø> (ø) ⬆️
fastapi/dependencies/utils.py 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 55afb70...f951305. Read the comment docs.

@tiangolo tiangolo merged commit c425509 into tiangolo:master Feb 4, 2020
@tiangolo
Copy link
Owner

tiangolo commented Feb 4, 2020

Awesome, thanks @dmontagu ! 🚀 🍰

And thanks for the clear explanation 🤓 🌮

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.

Sending incorrect data cause 500 error
2 participants