skip to Main Content

I have an API Gateway to unite multiple services under one URL. Problem is that the API Gateway works, but sometimes it returns 500 Internal server error. If I send the same request again with the same headers and same request body, it usually returns expected result.
The request doesn’t get to the corresponding services, as there are no mention of request in logs. There is however log in API Gateway, that just says "Internal server error", after expanding logs I figured that there is "api_configuration_error" but I don’t know what exactly it means, or how should I solve it.

Has someone met with this problem, if so, how did you solve it?

I tried creating new API and deleting old API and deploying old versions of the stages, but nothing changed.

3

Answers


  1. Chosen as BEST ANSWER

    This got resolved after removing the Hosted zone. Hosted zones used for services were "dev.service.xyz" for the development stage and "service.xyz" for the production stage. API gateway was set up so that users can point to any of these via stage functionality. For some reason, this caused that API gateway was able to resolve some requests for dev.service.xyz correctly and others incorrectly. After removing "service.xyz" and creating new "prod.service.xyz" for production resolved this issue.


  2. "api_configuration_error" can have the following causes, according to this:

    • when an invalid endpoint address is submitted,
    • when base64 decoding fails on binary data when binary support is enacted,
    • or when integration response mapping can’t match any template and no default template is configured.

    One of the first steps would be to try to extract the exact requests that are triggering the requests. API Gateway allows to log full request and responses to CloudWatch. With these it should be easy to re-construct the requests that are causing the problem.

    Login or Signup to reply.
  3. If you are receiving a 500 Internal Server Error when invoking an API Gateway HTTP API, you can troubleshoot the issue by enabling access logging for your API stage and including the $context.authorizer.error logging variable in your log format. If the logs indicate that API Gateway doesn’t have permission to invoke your function, update your function’s resource policy or provide an IAM role to grant API Gateway permission to invoke your authorizer. If the logs indicate that your Lambda function returns an invalid response, verify that your Lambda function returns a response in the required format. Additionally, you can use AWS X-Ray to determine the source of an error and its cause [1]. To customize the error response, you must catch errors in your code and format a response in the required format [2].

    [1] https://docs.aws.amazon.com/lambda/latest/dg/powershell-exceptions.html
    [2] https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-troubleshooting-lambda.html

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search