A client receives a 500 Internal Server Error when attempting to call an Amazon API Gateway resource secured by a custom Lambda Authorizer. The Lambda Authorizer execution completes successfully with no errors in its Amazon CloudWatch logs. Which of the following is the most likely cause of this behavior?
- The custom Lambda Authorizer returned a response JSON payload that does not conform to the expected format containing principalId and policyDocument.Answer
- BThe CORS configuration on the API Gateway resource is missing the Access-Control-Allow-Origin header.
- CThe client application sent an authorization token that is invalid or has expired.
- DThe backend integration Lambda function is returning a plain text string instead of a structured JSON response.
Answer
The custom Lambda Authorizer returned a response JSON payload that does not conform to the expected format containing principalId and policyDocument.
The correct response points out that a malformed JSON payload returned by the custom Lambda Authorizer (such as omitting principalId or policyDocument) causes API Gateway to fail validation, leading to a 500 Internal Server Error even if the Lambda code itself runs successfully without throwing errors.
Step-by-Step Solution
Key Concept
API Gateway Lambda Authorizer response validation