AWS Parameter caching layer error

0

We are currently using the AWS Parameter and Secrets Lambda extension for one of our lambdas. It is based on the guidance provided in the following AWS blog post: https://aws.amazon.com/blogs/compute/using-the-aws-parameter-and-secrets-lambda-extension-to-cache-parameters-and-secrets/. The setup: Python 3.9, architecture x86_64 , layer arn: arn:aws:lambda:eu-west-1:015030872274:layer:AWS-Parameters-and-Secrets-Lambda-Extension:4.

While the extension generally works well, every now and then we have been experiencing intermittent errors when trying to parse the response data returned by the extension's cache.

json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

This error occurs when we attempt to load the response data using the following piece of code:

response = json.loads(response.data)

That suggests the cache may sometimes contain invalid characters or empty strings. We can implement retry policy, but what can be a root cause of this issue ?

  • How does the response in those cases look like? Can you log the response structure in general and the response.data specifically? That would give you an idea what failed.

  • Sorry for late response. The additional information, when successful response.data is in format {"token": "xyz"} and once it fails response.data = 'not ready to serve traffic, please wait'. Looks like there is some time delay sometimes here for the layer.

1 Answer
0

It's almost impossible to guess the root cause of this issue given the provided information. It is always a good idea to handle known error-cases. If you log the response you may get additional information that leads you to the root cause.

To handle the error you could do:

    try:
        result = json.loads(response.data)
    except json.decoder.JSONDecodeError:
        log(response)
        result = {}
profile picture
answered a year 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