-
Notifications
You must be signed in to change notification settings - Fork 27
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
WIP: 🎨 Enh/error handler 500 #5487
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5487 +/- ##
=========================================
- Coverage 84.5% 76.3% -8.3%
=========================================
Files 10 1080 +1070
Lines 214 45119 +44905
Branches 25 551 +526
=========================================
+ Hits 181 34453 +34272
- Misses 23 10550 +10527
- Partials 10 116 +106
Flags with carried forward coverage won't be shown. Click here to find out more.
|
521380e
to
d165710
Compare
68e083d
to
5b5c3e2
Compare
735d33b
to
392b578
Compare
Quality Gate failedFailed conditions See analysis details on SonarCloud Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
* comply with new error response model * minor * If message is "", null or undefined, do not show it
392b578
to
b97bcd0
Compare
Quality Gate failedFailed conditions See analysis details on SonarCloud Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
What do these changes do?
This PR enhances aiohttp api errors and specifically those resulting from an unhandled exception. These changes were motivated by experiencing how some unhandled exceptions on the server were displayed to the user with an illegible message. In the event of an error, it is desirable:
errors middleware
packages/service-library/tests/aiohttp/test_rest_middlewares.py
enveloped responses
envelope_json_response
when applies. Why:simplified error response
The idea is to allow the front-end to have at least a human-readable message to display (i.e.
msg
) and eventually extra information.or for multiple errors
where only
msg
is required. Another example with extra context variables is thistest_requests_validation.py
status codes
status
module (i.e.from fastapi import status
orfrom servicelib.aiohttp import status
)serviceslib.status_utils
: helpers free functions for status codes. Renamed helpers combining names and numbers asstatus
does.test_how_status_codes_map_to_aiohttp_exception_class
we show that the lists of status codes differ in-
status
: the most complete list. Clear names and used by default.-
http.HTTPStatus
: python native. Provides phrases and short descriptions.-
aiohttp.web_exceptions
: Exception+Response classes for most of the status codes and extended to some more inservicelib.aiohttp.web_exceptions_extesion
Related issue/s
Follows up from series of PRs improving error handling repo-wide
How to test
Driving tests
NOTES:
SEE aio-libs/aiohttp#2415
NOTE that
aiohttp
deprecated returning theHTTPExceptions
and encourage them to be raised ...and this needs to change.