Skip to content

AWS Flask / Lambda Integration - AssertionError: popped wrong scope #190

Description

@iteratelance

When upgrading to 0.6.0 from 0.5.5 I started receiving this error:

[1543928085886] [INFO] 2018-12-04T12:54:45.869Z c6a7f732-f7c3-11e8-8354-13e650ef3e7e 104.63.241.241 - - [04/Dec/2018:12:54:45 +0000] "GET / HTTP/1.1" 200 56 "" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36" 0/1.58
[1543928085886] popped wrong scope: AssertionError
Traceback (most recent call last):
  File "/var/task/sentry_sdk/integrations/aws_lambda.py", line 37, in sentry_handler
  reraise(*exc_info)
  File "/var/task/sentry_sdk/hub.py", line 94, in __exit__
  assert layer[1] == self._layer[1], "popped wrong scope"
AssertionError: popped wrong scope

I upgraded to 0.6.1 and still receive the same error message.

The error results in API Gateway throwing a 502 error for every request regardless if the application throws an exception or not.

API Gateway response for every request result in.

{"message": "Internal server error"}

We are initiating the SDK as follows and using Lambda runtime Python 3.6

sentry_sdk.init(
    dsn=os.environ.get('SENTRY_DSN'),
    environment=os.environ.get('FLASK_ENV', 'development'),
    integrations=[FlaskIntegration(transaction_style='url'), AwsLambdaIntegration()]
)

Downgrading to 0.5.5 resolves the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions