getsentry / sentry-python

The official Python SDK for Sentry.io
https://sentry.io/for/python/
MIT License
1.93k stars 510 forks source link

Initializing Sentry in an AWS Lambda function handler fails with TypeError #3824

Closed pat-youda closed 3 days ago

pat-youda commented 3 days ago

Environment

SaaS (https://sentry.io/)

Steps to Reproduce

  1. Create a Lambda function that initializes Sentry like this:
    
    import sentry_sdk
    import sentry_sdk.integrations.aws_lambda as aws_lambda

sentry_sdk.init( dsn="...", environment="test", integrations=[aws_lambda.AwsLambdaIntegration()], release="...", debug=True )

**requirements.txt**:

boto3>=1.35.56,<2 pydantic>=2.9.2,<3 sentry_sdk>=2.19.0,<3


**Lambda runtime:** Python 3.12

### Expected Result

Sentry should be initialized and start capturing errors. In fact, my code works **AS IS** when run outside AWS Lambda (e.g., on my laptop).

### Actual Result

The `init` method raises a `TypeError`. Here is the according log statement from CloudWatch:

![Image](https://github.com/user-attachments/assets/de5e1d3c-1b56-4860-b32f-719721179ff5)

### Product Area

APIs

### Link

_No response_

### DSN

_No response_

### Version

_No response_
getsantry[bot] commented 3 days ago

Assigning to @getsentry/support for routing ⏲️

szokeasaurusrex commented 3 days ago

Hi @pat-youda, unfortunately the AwsLambdaIntegration is only supported on Python 3.9. We already have an issue open to add support for Python 3.12, but since we are busy with other priorities, it will take us some time to get around to implementing this.

I noticed that we are missing documentation that states that Python 3.9 is the only version we support for the AwsLambdaIntegration, so I created https://github.com/getsentry/sentry-docs/issues/11952 to make sure we add this information to the docs page.

Also, I am opening #3825 to add a warning when the integration is initialized with an unsupported Python version.

I am going to close this issue in favor of the other issues linked in this comment. Please reach out if you have any further questions.

pat-youda commented 3 days ago

I see. Thanks for the quick reply @szokeasaurusrex.