Skip to content

Execution failed due to configuration error: Request body validation took too long

0

I have a REST API endpoint in API Gateway with a configured request validator:

x-amazon-apigateway-request-validators:
  all:
    validateRequestParameters: true
    validateRequestBody: true

I get the following error If I try to post a json body above about 2 MB: "Execution failed due to configuration error: Request body validation took too long" I am unable to find any information about limits or quotas regarding this. Is there anything I can do beside turning validation off?

asked 2 years ago377 views

1 Answer
0

The issue you're experiencing with the "Request body validation took too long" error for JSON bodies above 2 MB is related to API Gateway's request validation limitations. While API Gateway does offer request validation capabilities, there are some constraints to be aware of when dealing with larger payloads.

Unfortunately, there isn't a direct way to increase the validation limit for large request bodies in API Gateway. The 10 MB payload limit for API Gateway is a hard limit that cannot be increased, and it appears that the validation process has an even lower practical limit of around 2 MB.

Given this constraint, you have a few options to consider:

  1. Turn off request body validation: This is not ideal if you need to ensure the integrity of the incoming data, but it would allow larger payloads to pass through.

  2. Implement client-side validation: Move the validation logic to the client side to ensure data integrity before sending it to the API.

  3. Use S3 for large file uploads: For payloads exceeding the practical validation limit, you could implement a two-step process: a. Generate a pre-signed S3 URL through your API. b. Have the client upload the large file directly to S3 using the pre-signed URL. c. Process the file from S3 after the upload is complete.

  4. Compress the payload: If possible, compress the JSON payload on the client-side before sending it to API Gateway. However, be aware that API Gateway may attempt to decompress the payload before forwarding it to the integration, which could still lead to issues if the decompressed size exceeds 10 MB.

  5. Split large payloads: If feasible, consider breaking up large payloads into smaller chunks and sending them in multiple requests.

  6. Use a different service: For consistently large payloads, you might want to consider using a different AWS service that's better suited for handling large data transfers, such as AWS Transfer for SFTP or direct S3 uploads.

While these options provide workarounds, they each have trade-offs in terms of complexity, security, and user experience. The best approach will depend on your specific use case and requirements.

Sources
AWS API GW with POST request payload more than 10MB | AWS re:Post
Request validation for REST APIs in API Gateway - Amazon API Gateway

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.