Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when requestContext is None #289

Closed
scottmn opened this issue Sep 23, 2021 · 1 comment · Fixed by #290
Closed

Error when requestContext is None #289

scottmn opened this issue Sep 23, 2021 · 1 comment · Fixed by #290

Comments

@scottmn
Copy link

scottmn commented Sep 23, 2021

Python Version

3.8

Package Version

2.12.0

Description

I have a lambda that is called through API Gateway, but can also be invoked directly via a lambda client. Upgrading to 2.12.0 started causing this error when invoked via client.

[ERROR] TypeError: argument of type 'NoneType' is not iterable
Traceback (most recent call last):
  File "/var/task/apig_wsgi/__init__.py", line 61, in handler
    if "requestContext" in event and "elb" in event["requestContext"]:

This is being done from Kotlin code, using com.amazonaws.services.lambda.AWSLambda client. When an AwsProxyRequest object is constructed, it has requestContext=null by default. This results in the error above.

I can update my invoke code to set a dummy requestContext, but I do believe it is valid to be None in the direct lambda invocation use case. Does it make sense to add a not None check here for requestContext?

Thanks.

@adamchainz
Copy link
Owner

Indeed it makes sense to add the check. Fixed in #290, released in 2.12.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants