-
Notifications
You must be signed in to change notification settings - Fork 401
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
Bug: Error handler fails to parse pydantic models #3451
Comments
hey @dacianf thanks a lot for opening this. remapped as a feature since that was intentional - I'm gonna work on this. Meanwhile, you can workaround by dumping the model as JSON in the body. Background. When writing the docs before the launch, we noticed there wasn't a mechanism to override the validation error to allow standardization by customers. While we did ( For the time being, I'll treat as a feature, and handle both Pydantic and Dataclasses in the response builder. |
Agreed with @leandrodamascena that we should treat as a bug due to hyrum law (someone will depend on this to work implicitly). PR is up, we just need to test Pydantic v1/v2 compatibility and we should be good to release this so you don't depend on workarounds :-). |
@dacianf done! Leandro is out for the day, unless that's a major blocker for you, I'd like to get a second pair of eyes before we merge and make a hotfix release to get this over to you tomorrow. Let me know otherwise :) |
|
releasing now - 2.29.0. |
This is now released under 2.29.0 version! |
Expected Behaviour
When I return a Response with a pydantic model in an exception handler function I expect it to be able to serialize it successfully
Current Behaviour
It throws an error:
Object of type ErrorModel is not JSON serializable
Code snippet
Possible Solution
No response
Steps to Reproduce
ErrorModel
Response[ErrorModel]
, e.g:Powertools for AWS Lambda (Python) version
latest
AWS Lambda function runtime
3.11
Packaging format used
Lambda Layers
Debugging logs
The text was updated successfully, but these errors were encountered: