Sentry-python: AWS Lambda under Python 3.8 is currently broken

Created on 22 Jul 2020  路  8Comments  路  Source: getsentry/sentry-python

It seems they have done some updates on the runtime that broke our integration.

bug

Most helpful comment

0.16.3 is out which fixes the problem.

All 8 comments

Seems to work again
image

Thanks for notifying, let's try it out.

I'm also facing issues with AWS lambda and python3.8 runtime.
It was working just fine 20 days ago (have some entries on sentry server), currently it's not working.

I've tested following code:

import json
import sentry_sdk
import logging
from sentry_sdk.integrations.aws_lambda import AwsLambdaIntegration



sentry_sdk.init(
    "[hidden]",
    integrations=[AwsLambdaIntegration()],
    debug=True
)


def lambda_handler(event, context):

    logging.error('this will get logged')

    # this will not get triggered
    raise IndexError

    return {
        'statusCode': 200,
        'body': json.dumps('Hello from Lambda!')
    }

Here's the lambda execution results

Response:
{
  "statusCode": 200,
  "body": "\"Hello from Lambda!\""
}

Request ID:
"ecc62a58-abd1-4d2b-832c-697cfb81bb89"

Function logs:
START RequestId: ecc62a58-abd1-4d2b-832c-697cfb81bb89 Version: $LATEST
[ERROR] 2020-07-28T09:43:21.823Z    ecc62a58-abd1-4d2b-832c-697cfb81bb89    this will get logged
 [sentry] DEBUG: Flushing HTTP transport
[DEBUG] 2020-07-28T09:43:22.839Z    ecc62a58-abd1-4d2b-832c-697cfb81bb89    Flushing HTTP transport
 [sentry] DEBUG: Sending event, type:null level:error event_id:01e178eb22864dc6ae242309d8844717 project:[hidden] host:[hidden]
 [sentry] DEBUG: background worker got flush request
[DEBUG] 2020-07-28T09:43:22.840Z    ecc62a58-abd1-4d2b-832c-697cfb81bb89    Sending event, type:null level:error event_id:01e178eb22864dc6ae242309d8844717 project:[hidden] host:[hidden]
[DEBUG] 2020-07-28T09:43:22.859Z    ecc62a58-abd1-4d2b-832c-697cfb81bb89    background worker got flush request
 [sentry] DEBUG: 0 event(s) pending on flush
[DEBUG] 2020-07-28T09:43:22.979Z    ecc62a58-abd1-4d2b-832c-697cfb81bb89    0 event(s) pending on flush
 [sentry] DEBUG: background worker flushed
[DEBUG] 2020-07-28T09:43:23.113Z    ecc62a58-abd1-4d2b-832c-697cfb81bb89    background worker flushed
END RequestId: ecc62a58-abd1-4d2b-832c-697cfb81bb89
REPORT RequestId: ecc62a58-abd1-4d2b-832c-697cfb81bb89  Duration: 1291.55 ms    Billed Duration: 1300 ms    Memory Size: 128 MB Max Memory Used: 64 MB  Init Duration: 220.85 ms    

In this case logging.error will be sent as an event to sentry, however raised exception will not.
If I omit the logging part, nothing gets to sentry server.

And everything just works as expected on python3.7 runtime

Running the function code locally with python3.8 works just fine.

I also have same problem today.
In my environment, It seems bootstrap is not patched well.

import sentry_sdk
from sentry_sdk.integrations.aws_lambda import AwsLambdaIntegration
import traceback

sentry_sdk.init(
    dsn="*****",
    integrations=[AwsLambdaIntegration()]
)

def hello(event, context):
    traceback.print_stack()

This code returns

```python:3.8
File "/var/runtime/bootstrap.py", line 486, in
main()
File "/var/runtime/bootstrap.py", line 474, in main
handle_event_request(lambda_runtime_client,
File "/var/runtime/bootstrap.py", line 131, in handle_event_request
response = request_handler(event, lambda_context)
File "/var/task/handler.py", line 13, in hello
traceback.print_stack()


on lambda Python3.8.
`handle_event_request` is not patched.

On the other hand, on lambda Python3.7,

```python:3.7
  File "/var/runtime/bootstrap", line 9, in <module>
    main()
  File "/var/runtime/bootstrap.py", line 365, in main
    event_request.deadline_time_in_ms)
  File "/var/task/sentry_sdk/integrations/aws_lambda.py", line 136, in sentry_handle_event_request
    lambda_runtime_client, request_handler, *args, **kwargs
  File "/var/runtime/bootstrap.py", line 131, in handle_event_request
    response = request_handler(event, lambda_context)
  File "/var/task/sentry_sdk/integrations/aws_lambda.py", line 48, in sentry_handler
    return handler(event, context, *args, **kwargs)
  File "/var/task/handler.py", line 13, in hello
    traceback.print_stack()

handle_event_request is replaced to sentry_handle_event_request.

Hey all, we'll have resources to fix this in the next two weeks. Just for my understanding, is downgrading to 3.7 a feasible workaround for everybody right now?

I

Hey all, we'll have resources to fix this in the next two weeks. Just for my understanding, is downgrading to 3.7 a feasible workaround for everybody right now?

I was trying to upgrade when a noticed the problem. I will hold the upgrade for now, thank you for the reply.

Hey all, we'll have resources to fix this in the next two weeks. Just for my understanding, is downgrading to 3.7 a feasible workaround for everybody right now?

We can't easily downgrade to 3.7. We will hope for a fix sooner rather than later.

0.16.3 is out which fixes the problem.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

miracle2k picture miracle2k  路  6Comments

synic picture synic  路  5Comments

steven-murray picture steven-murray  路  3Comments

hyperknot picture hyperknot  路  4Comments

MaximZemskov picture MaximZemskov  路  3Comments