-
Notifications
You must be signed in to change notification settings - Fork 403
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: event_parser decorator catches an irrelevant AttributeError and raises InvalidModelTypeError exception. #5705
Comments
Thanks for opening your first issue here! We'll come back to you as soon as we can. |
Hey @junkor-1011 ! Thank you so much for opening this issue. We'll evaluate and get back to you soon. 🚀 |
|
This is now released under 3.4.0 version! |
Expected Behaviour
The expected behavior is that exceptions related to Powertools do not arise from the event_parser decorator in code like the following:
Assume that the
event
is in a format that matches theEventModel
by pydantic and is correctly parsed.Therefore, the exception happening in the above code has nothing to do with powertools event_parser.
Current Behaviour
InvalidModelTypeError occurs within powertools, as shown below:
I consider it very confusing because even if the event validation in the event_parser decorator succeeds, the above exception is raised.
Code snippet
Possible Solution
Currently (v3.3.0), AttributeError is caught at the error location in powertools as follows:
https://github.com/aws-powertools/powertools-lambda-python/blob/v3.3.0/aws_lambda_powertools/utilities/parser/parser.py#L114
Is it problematic to rewrite this part to catch Pydantic-derived Exceptions (e.g. pydantic.ValidationError) instead of AttributeError?
Steps to Reproduce
# requirements.txt annotated-types==0.7.0 aws-lambda-powertools==3.3.0 jmespath==1.0.1 pydantic==2.10.3 pydantic-core==2.27.1 typing-extensions==4.12.2
Powertools for AWS Lambda (Python) version
3.3.0
AWS Lambda function runtime
3.12
Packaging format used
PyPi
Debugging logs
The text was updated successfully, but these errors were encountered: