-
Notifications
You must be signed in to change notification settings - Fork 421
Bug: APIGatewayRestResolver exception_handler decorator is not stackable #1706
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
Comments
Thanks for opening your first issue here! We'll come back to you as soon as we can. |
If happy I can raise a PR |
Hey @sprkem, let's extend the signature to accept one or more exceptions (Exception | List[Exception]) instead. Stacking will impact performance with the increase of stack frames. We should support it to prevent errors, but the intention we need to address is to handle distinct yet related exceptions with a single exception handler. Yes, please for the PR!! Ping if you need any help Thank you! |
I have raised this now: #1707 |
|
This is now released under 2.3.0 version! |
Expected Behaviour
I would expect to be able to decorate an exception handler multiple times to reuse handler code.
Current Behaviour
The first decorator (immediately above the function header) is handled correctly, however subsequent decorators are assigned
None
in the map and are therefore not handled. In the example above, aSchemaValidationError
would result in a 502 Internal Server error response to the user.Code snippet
Possible Solution
Return the function in the inner function:
Steps to Reproduce
Add some logging to powertools for illustration:
Run the code snippet above. Note the output e.g.
{<class 'aws_lambda_powertools.event_handler.exceptions.BadRequestError'>: <function something at 0x108813310>, <class 'aws_lambda_powertools.utilities.validation.exceptions.SchemaValidationError'>: None}
AWS Lambda Powertools for Python version
37
AWS Lambda function runtime
3.9
Packaging format used
Lambda Layers
Debugging logs
No response
The text was updated successfully, but these errors were encountered: