Open
Description
Expected Behaviour
When log_uncaught_exceptions=True
, uncaught exceptions in a lambda are handled and transformed to a structured log.
Current Behaviour
Uncaught exceptions are printed unstructured.
Code snippet
from aws_lambda_powertools import Logger
from aws_lambda_powertools.utilities.typing import LambdaContext
logger = Logger(log_uncaught_exceptions=True)
def lambda_handler(event: dict, context: LambdaContext) -> str:
raise(Exception("asdf"))
Possible Solution
Probably none. Document this behavior.
I don't think sys.excepthook
can be overridden in a lambda container, but I have no proof because the original forum thread that details this has been deleted by AWS with no replacement.
Steps to Reproduce
Set log_uncaught_exceptions=True in an actual running lambda. If log_uncaught_exceptions=True on a local machine, the behavior runs just as intended.
AWS Lambda Powertools for Python version
latest
AWS Lambda function runtime
3.9
Packaging format used
Lambda Layers
Debugging logs
No response