-
-
Notifications
You must be signed in to change notification settings - Fork 330
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
feat: problem details plugin #3323
base: main
Are you sure you want to change the base?
Conversation
* feat: Added precedence of CLI parameters over envs * Update docs/usage/cli.rst Co-authored-by: Peter Schutt <peter.github@proton.me> * Remove redundant LitestarEnv fields and fix tests * Update docs/usage/cli.rst * Update litestar/cli/commands/core.py * Update docs/usage/cli.rst * Update docs/usage/cli.rst * Update litestar/cli/commands/core.py --------- Co-authored-by: kedod <kedod> Co-authored-by: Peter Schutt <peter.github@proton.me> Co-authored-by: Jacob Coffee <jacob@z7x.org>
…on from HTTPException
It looks like you are adding a new feature! 🚀 Please rebase and point your PR to the |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3323 +/- ##
==========================================
- Coverage 98.28% 98.27% -0.01%
==========================================
Files 324 325 +1
Lines 14774 14830 +56
Branches 2344 2352 +8
==========================================
+ Hits 14520 14574 +54
- Misses 116 117 +1
- Partials 138 139 +1 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. This looks useful. LGTM
If `extra` is a `Mapping` then we'll merge that into the final problem details JSON to keep it similar to how it is in the RFC.
What is the status on this? |
At risk of stating the obvious, it looks like its waiting on some comments to be resolved and a rebase. |
I'll get it fixed in a few days. I've been a bit busy. |
74fabb5
to
c543cb9
Compare
Co-authored-by: Jacob Coffee <jacob@z7x.org>
Documentation preview will be available shortly at https://litestar-org.github.io/litestar-docs-preview/3323 |
69f34bd
to
6460f0a
Compare
Quality Gate passedIssues Measures |
problem_details.update(extra) | ||
else: | ||
problem_details["extra"] = extra | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't there some strange redundancy in these conditionals?
Both L88 and L91 check if self.extra is a Mapping, meaning that if it is a Mapping, L92 will never happen. Right?
To me, it looks like L91-93 can be removed and L94 can be unindented one step to replace the whole interior conditional.
Description
A plugin to enable usage of problem details as the response.
The way this works is by injecting an exception handler into the app level exception handlers to convert
ProblemDetailsException
into a response following the specification as per RFC 9457.Users can pass in a mapping of exception types to callables that will convert those exception types into
ProblemDetailsException
for handling specific exceptions such as pydantic'sValidationError
. That convertedProblemDetailsException
will then be used to create the response. This should allow for flexibility when needed.Closes
Closes #3199.