Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix body parsing#918

Merged
tiangolo merged 2 commits into
fastapi:masterfrom
dmontagu:fix-body-parsing
Feb 4, 2020
Merged

Fix body parsing#918
tiangolo merged 2 commits into
fastapi:masterfrom
dmontagu:fix-body-parsing

Conversation

@dmontagu

Copy link
Copy Markdown
Contributor

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.

return values, errors


def get_missing_field_error(field_alias: str) -> ErrorWrapper:

Copy link
Copy Markdown
Contributor 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

codecov Bot commented Jan 25, 2020

Copy link
Copy Markdown

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 fastapi:master Feb 4, 2020
@tiangolo

tiangolo commented Feb 4, 2020

Copy link
Copy Markdown
Member

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