When we update the Lambda function like below
Before update (snippet):
cookie_present = event_headers.get("cookie")
if not cookie_present:
cookie.load(event_headers["Cookie"])
auth_access_token = cookie["auth_access_token"].value
After update:
cookie_present = event_headers.get("cookie")
if not cookie_present:
print("inside if cookie_present")
cookie.load(event_headers["Cookie"])
else:
print("inside else cookie_present")
cookie.load(event_headers["cookie"])
auth_access_token = cookie["auth_access_token"].value
Upon executing the lambda function after the update, we can see the following errors in the cloudwatch logs
[ERROR] Runtime.UserCodeSyntaxError: Syntax error in module 'lambda_function': invalid syntax (lambda_function.py, line 112)
Traceback (most recent call last):
File "/var/task/lambda_function.py" Line 112
auth_access_token = cookie["auth_access_token"].value
But there is no syntax error in the code, we tried to update the same extact code in a another different lambda function, there the same function executed properly without any issues. ( i.e no syntax error ).
We also faced similar kind of issues in other lambda functions but upon redeployment they are executing properly without any issues. Can you please help us to find out the exact reason for this or this there anything to do with lambda itself?
More details: We are using Python 3.9 runtime Architecture x86_64