Skip to content

Bug: log_uncaught_exceptions only works locally and not on lambda #1798

Open
@bellis-ai

Description

@bellis-ai

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug-upstreamSomething isn't working in an upstream dependencyloggerrevisit-in-3-monthsRequires more customers feedback before making or revisiting a decision

    Type

    No type

    Projects

    Status

    On hold

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions