8000 Better JSON Decode error handling by aviramha · Pull Request #1354 · fastapi/fastapi · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
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

Better JSON Decode error handling #1354

Merged
merged 3 commits into from
Jun 13, 2020
Merged

Conversation

aviramha
Copy link
Contributor

I was annoyed by the fact that if JSON parsing fails for the body you receive HTTP Exception 400.
I think RequestValidationError is a better suit for the case, for the client to realize what have he done wrong exactly (position of wrong character) and body to be part of the exception (so it can be logged)

@codecov
Copy link
codecov bot commented Apr 30, 2020

Codecov Report

Merging #1354 into master will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master     #1354   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          226       227    +1     
  Lines         6785      6813   +28     
=========================================
+ Hits          6785      6813   +28     
Impacted Files Coverage Δ
fastapi/routing.py 100.00% <100.00%> (ø)
tests/test_tutorial/test_body/test_tutorial001.py 100.00% <100.00%> (ø)
fastapi/applications.py 100.00% <0.00%> (ø)
...orial/test_conditional_openapi/test_tutorial001.py 100.00% <0.00%> (ø)

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 4e77737...abe1cd9. Read the comment docs.

@aviramha
Copy link
Contributor Author

@tiangolo Seems the new handling leaves the generic exception handling uncovered. Not sure how to trigger that exception now tho, would assume connection breaking or something similar. ideas?

@aviramha
Copy link
Contributor Author

Added missing test for full coverage, pending CR @tiangolo .

@tiangolo tiangolo merged commit b13a4ba into fastapi:master Jun 13, 2020
@tiangolo
Copy link
Member

Awesome! Very nice 👌 ✨

Impeccable implementation and tests ✔️ 🚀

Thanks for your contribution! 🎉 🍰

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.

2 participants
0