Closed jeffcarrico closed 2 months ago
hey @jeffcarrico! This is a known limitation of msgspec, which Litestar uses to provide (part of) its attrs support.
There's an open issue over at their repo for this as well.
The partial msgspec support however means that it's hard for us to work around this, as msgspec doesn't give us a way to hook into the de/encoding process there for types it supports natively.
I think as of now, the workaround you're using in your test2
is the best solution.
Description
Attrs has an attribute conversion feature where a function can be provided to be run whenever the attribute value is set.
https://www.attrs.org/en/stable/examples.html#conversion
This is not being run when the post request body is an attrs class. Looking for clarity on if this is by design or a fix if not. Also, is there another preferred pattern in litestar to do this type of payload attribute conversion?
URL to code causing the issue
No response
MCVE
requirements.txt
api.py
Steps to reproduce
litestar --app api:app run
Screenshots
No response
Logs
No response
Litestar Version
2.10.0
Platform