Skip to content

Ability to disable the API Gateway Request Validator on v2 #10229

@jweyrich

Description

@jweyrich

Are you certain it's a bug?

  • Yes, it looks like a bug

Is the issue caused by a plugin?

  • It is not a plugin issue

Are you using the latest version?

  • Yes, I'm using the latest version

Is there an existing issue for this?

  • I have searched existing issues, it hasn't been reported yet

Issue description

We migrated some of our projects from Serverless 1.83 to ^2.60 and we are facing an issue related to Request Validators being created and enabled automatically for us on the API Gateway.

This seems related to these commits:

All our Lambda functions have JSON Schemas defined in serverless.yml, but we never relied on the Request Validator from API Gateway. We have specific code in our Lambdas to validate request body, headers and parameters. Now that we migrated to ^2.60, we noticed our APIs are deployed to the API Gateway with a Request Validator enabled for each endpoint.

I searched for issues related to "Request Validator" and found many people asking the opposite - to enable the request validator, to make it work, to enable it, etc. But since we have complex validation logic in some cases that are not supported by JSON schema, we cannot currently rely on the validations based on the JSON Schema.
The situation now is that some of our responses are being rejected by API Gateway as Bad Request, and the default BadRequest response is being sent. If the validation passes the API Gateway validator, but doesn't pass our Lambda logic that has all complex validations, it returns BadRequest with a completely diferent response from that from API Gateway. We could define a custom response for BadRequest to make it look like the from our Lambda, but as I said, we don't need the API Gateway request validator - in fact, we don't want it - since we already have all validation logic in a single place (Lambda code) that supports all kinds of complex conditions we need.

Is there an option to disable the request validator? An opt-out configuration that we can add to the serverless.yml to disable this behavior?

I reported as a bug since it looks like a new feature in v2 that caused regression to our APIs that were previously running ok on v1. I failed to find a reference or changelog explaining that behaviour as well. Feel free to update/change this issue to reflect what it looks like to you (maybe a feature request?).

Service configuration (serverless.yml) content

Maybe N/A. It has almost 2k lines and split in different yamls.

Command name and used flags

serverless.js deploy --stage $STAGE --package .artifacts

Command output

N/A

Environment information

Framework Core: 2.66.1 (local)
Plugin: 5.5.0
SDK: 4.3.0
Components: 3.17.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions