Syntax error in AWS python Lambda function

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 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

1 Answer
0

Would it be possible for you to share the full text of the code?
The current possible cause of the error may be that the event_headers does not have the proper value.

profile picture
EXPERT
answered 10 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions