Error when requestContext is None
Closed this issue · 1 comments
scottmn commented
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 commented
Indeed it makes sense to add the check. Fixed in #290, released in 2.12.1.