From adbe15e3224ddfc9e5602fca59210fc06339d4a4 Mon Sep 17 00:00:00 2001 From: Joe Haines Date: Thu, 11 Apr 2024 15:30:45 +0100 Subject: [PATCH] Fix unhandled exceptions in lambdas being handled --- bugsnag/client.py | 7 ++++++- tests/test_client.py | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/bugsnag/client.py b/bugsnag/client.py index 987ab517..558b074a 100644 --- a/bugsnag/client.py +++ b/bugsnag/client.py @@ -476,7 +476,12 @@ def report_timeout_to_bugsnag(): return real_handler(aws_event, aws_context) except Exception as exception: if self.configuration.auto_notify: - self.notify(exception) + self.notify( + exception, + unhandled=True, + severity='error', + severity_reason={'type': 'unhandledException'}, + ) raise finally: diff --git a/tests/test_client.py b/tests/test_client.py index 285b3ddd..f01b8589 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -1843,6 +1843,7 @@ def my_handler(event, context): payload = self.server.events_received[0]['json_body'] event = payload['events'][0] + assert event['unhandled'] assert event['exceptions'][0]['message'] == 'oh dear' assert event['metaData']['AWS Lambda Event'] == {'a': 1} assert event['metaData']['AWS Lambda Context'] == { @@ -1878,6 +1879,7 @@ def my_handler(event, context): payload = self.server.events_received[0]['json_body'] event = payload['events'][0] + assert event['unhandled'] assert event['exceptions'][0]['message'] == 'oh dear' assert event['metaData']['AWS Lambda Event'] == {'z': 9} assert event['metaData']['AWS Lambda Context'] == {