AWS Lambda errors not sent to Sentry

I have a simple AWS Lambda function for which nothing is reported to Sentry when exceptions occur. Below is my code which triggers a ZeroDivisionError. I have tried with several other errors as well, but none of them are reported to Sentry. What’s weird is that if I do sentry_sdk.capture_message('test'), it works just fine. So Sentry is set up just fine and the the connection must be fine, as are the environment variables. Exceptions are just not caught.

my_project/logging_setup.py

import os
import sentry_sdk
from sentry_sdk.integrations.aws_lambda import AwsLambdaIntegration


def init():
    sentry_sdk.init(
        dsn=os.environ['SENTRY_DSN'],
        integrations=[AwsLambdaIntegration()],
        environment=os.environ['ENVIRONMENT']
    )

my_project/handlers.py

from logging_setup import init as sentry_init

sentry_init()  # Configure Sentry


def my_handler(event, context):
    from test_package.listener import handler
    return handler(event, context)

my_project/test_package/listener.py

def handler(event, context):
    # Trigger ZeroDivisionError. Doesn't end up in Sentry. Neither do other exceptions.
    if 58 / 0 == 1:
        raise Exception('...')

Am I missing any limitations for the Python SDK? FWIW, I’ve had this in production for a year and I have previously received errors within Sentry. Today I upgraded my Lambda function to Python 3.8 and updated the SDK to the latest verrsion, and now nothing, although I’m not sure if it’s related.

I can see the errors in my CloudWatch logs just fine, e.g.:

[ERROR] ZeroDivisionError: division by zero
Traceback (most recent call last):
  File "/var/task/handlers.py", line 6, in my_handler
    return handler(event, context)
  File "/var/task/test_package/listener.py", line 3, in handler
    if 58 / 0 == 1:

Any ideas? Thanks!

You’re hitting https://github.com/getsentry/sentry-python/issues/764
– we will have resources to fix this in the next two weeks.

Ah, I see. Thanks! :slightly_smiling_face: