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: add pydantic's error dict to ValidationException #3467
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3467 +/- ##
=======================================
Coverage 98.29% 98.29%
=======================================
Files 328 328
Lines 14865 14868 +3
Branches 2358 2359 +1
=======================================
+ Hits 14611 14614 +3
Misses 116 116
Partials 138 138 ☔ View full report in Codecov by Sentry. |
Documentation preview will be available shortly at https://litestar-org.github.io/litestar-docs-preview/3467 |
@@ -61,6 +61,7 @@ class ErrorMessage(TypedDict): | |||
key: NotRequired[str] | |||
message: str | |||
source: NotRequired[Literal["body"] | ParamType] | |||
exc: NotRequired[Dict[str, Any]] |
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.
I think a different name like errors
or something may be better since exc
is usually used to mean an exception. Wdyt?
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.
Good point. This will contain data of a single error and will be accessed with validation_exception["extra"][0]["exc"]
.
How about raw
, detail
or error_detail
?
I'm not enthusiastic about adding more pydantic specific handling in our core, and wonder if there's not a way we can better manage this type of thing with our plugin architecture. We have this |
This approach feels more accessible. I'll try to implement this. |
Cool, feel free to share early thoughts and if you have any questions I'll do my best to try and answer them. Perhaps best to do this in another branch in case we hit a dead end and end up back here? |
Description
SignatureModel
's_build_error_message
method to accept an optional error dict and add it to the message.Closes #3466