0

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 exact 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
RF1991
  • 2,037
  • 4
  • 8
  • 17
Mounick
  • 171
  • 5
  • Not sure how you are deploying but perhaps viewing the code itself in the console if it lets you or export the function from the console and see if anything is amiss. – cyberwombat Jul 18 '23 at 13:56
  • It could be a versioning issue as suggested [here](https://stackoverflow.com/a/67417792/11072533), but since `Runtime.UserCodeSyntaxError` seems to be a custom AWS error, I'm not really sure what could be causing it. Is that the entire traceback? – Cmd858 Jul 18 '23 at 15:27

0 Answers0