Closed peterschutt closed 8 months ago
Reproduces on litestar==2.5.1
/ pydantic==2.5.3
.
Turns out this isn't really a bug as such and has nothing to do with the field_validator
in particular. It's just that Pydantic v2 return the original ValueError
raised as part of its own exception when formatted as a dict. Since we in turn pass this to our ValidationException
, and later on try to serialize it, we're hitting a serialization error because we can't actually serialize ValueError
.
The reason why this only affects DTOs is because they take a very different error handling path; This also results in slightly different error responses when DTOs are used.
@peterschutt I think we should tackle this for v3 as it can only be done with breaking changes.
This issue has been closed in #3286. The change will be included in the upcoming patch release.
A fix for this issue has been released in v2.8.0
Discussed in https://github.com/orgs/litestar-org/discussions/2363
Funding