Origin Request Lambda Returns 400

0

Hi,

I have an issue with an Origin Request Lambda@Edge lambda. After it returns the modified request object the request throws an error and returns a 400. (I checked the requests never reached the Origin) and also the x-cache header of the response is "Error from CloudFront".

Now I have a suspicion that the reason for that behavior is that the uri field is the following - "uri": "/cohesionapi/entity-preview/[media-reference:media:e44cf764-a581-4e26-903d-fc0ef5369738]" - do you think that the [ would break CloudFront, or is it a valid response/request to make?

Thanks Sandor

asked 2 years ago883 views
1 Answer
0

I am not sure about the URI format, but a few things to try to get started:

  1. Can you look at the 400 response body? Sometimes the response error body has useful information that can point in the right direction. Try pulling the URL up in a browser.
  2. The Error from CloudFront means the request is probably malformed, which might align with your theory on the uri format. If it was an issue with the Lambda logic you would likely get a 502 and the x-cache header would be LambdaValidationError or LambdaExecutionError.
  3. Is there anything meaningful in the CloudWatch logs that might point you in the right direction?
  4. Consider logging the event object at the end of your L@E function. I am not sure which language you are using, but for node I usually do something like the following. You should see the output in the CloudWatch logs which might point to the issue. Start by checking the event.request.origin object to see if everything looks correct there.

console.log(JSON.stringify(event));

profile pictureAWS
answered 2 years 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