-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot call request validator options multiple times. #7613
Comments
Thanks for filing this @durja. This is, in fact, a bug on the CDK. You can workaround this by using the |
The proposed solution is to remove the requestValidatorOptions property completely, And add in
I can't actually create the new class object without it failing at the above line.
|
@monkeytronics changing the implementation throws another error Caused by: java.lang.NullPointerException: restApi is required |
Hi folks, will this be fixed eventually? |
I had to remove validation also :( |
Was able to get around this by creating a validator object. const queryStringValidator = new apigateway.RequestValidator(
scope,
"validator",
{
restApi: api,
requestValidatorName: "validator",
validateRequestBody: false,
validateRequestParameters: true,
}
);
resource.addMethod(
"GET",
new apigateway.LambdaIntegration(this.lambdaFunc),
{
requestParameters: {
"method.request.querystring.attribute": true,
},
requestValidator: queryStringValidator,
}
); |
Not the most elegant solution, but here is what I'm using: const getMethodOptions = (model?: Model): MethodOptions => {
const methodOptions: MethodOptions = {
authorizer: tokenAuthorizer,
requestParameters: {
"method.request.header.authorization": true,
},
requestModels: {},
// https://github.com/aws/aws-cdk/issues/7613
requestValidator: new RequestValidator(
this,
"AppApiRequestValidator" + this.requestValidatorSuffix,
{
restApi: appApi,
validateRequestParameters: true,
validateRequestBody: Boolean(model),
}
),
};
this.requestValidatorSuffix++;
if (model) {
return {
...methodOptions,
requestModels: { "application/json": model },
};
}
return methodOptions;
}; |
Hi there 👋 It has been about over a year and a half since this has been reported, what is the status on this? Thanks! |
NOTE: The requestValidatorOptions had to be broken out into individual objects. Refer to: aws/aws-cdk#7613
NOTE: The requestValidatorOptions had to be broken out into individual objects. Refer to: aws/aws-cdk#7613
This issue has received a significant amount of attention so we are automatically upgrading its priority. A member of the community will see the re-prioritization and provide an update on the issue. |
* feat: Adds formal API path for playerHand The `playerHand` path has been added to the legalBrawl API. This will be the destination where POST requests are made by the game client to submit, and in return receive an opposing player's selected cards. A model has been added to ensure that the body's JSON data is valid before it reaches the Lambda (though this doesn't stop unsanitary inputs, it's a matter of validation at a schema-level). * feat: Adds handling for POST reqs to playerHand A first-cut of handling logic for POST requests to `playerHand` has been added. Currently, this only *submits* `playerHandInfo` payloads into the `playerHands` database. This change provides the capability for an HTTP POST request of a specific format to be inserted into the `playerHands` dynamoDB database using the `PutItem` API. Known Bugs: - There is currently an unhandled scenario where if an entry already exists, it should return an error - When marshalling the Golang struct to a DynamoDB struct using `MarshalMap`, there doesn't seem to be any indication that the payload coming in is bogus. For example, a field could be called "hand" rather than "card". This causes the data for the unmatching field to be "Null". * refactor: Reorganizes aws package The `aws` package use by the `legalbrawlapi` module is getting needlessly deep, and is causing circular dependencies. Because the API gateway request body is being used by DynamoDB in `PutItem` requests (among others). This "flattening" of the structure should better support the requirements that these two components have. * refactor: Merges struct types Throughout the API Gateway and DynamoDB code, there were similarities that were suitable to merge into common struct types. The benefit of this is that bespoke "conversion" logic isn't necessary if HandInfo is a 1:1 to its DynamoDB counterpart. So in theory the body coming in from the request can immediately be used in the `PutItem` API call. This results in (hopefully) maintable code, while also still being terse. * refactor: Changes type scopes for aws package to private * chore: Tweaks HandleRequest function * doc: Adds docstring to addHand method * doc: Removes "bug" regarding duplicate hands. Players may be using their existing hand for matchmaking. Since DynamoDB doesn't duplicate entries anyway. This isn't a bug as far as we would be concerned. This may change as requirements evolve. * feat: Adds POST and GET to playerHands API * feat: Adds timeout to playerHands GET request * feat: Adds timeout to playerHands POST request * feat: Adds PUT method to API * feat: Adds validation to POST & PUT methods NOTE: The requestValidatorOptions had to be broken out into individual objects. Refer to: aws/aws-cdk#7613 * feat: Adds validation to GET method * feat: Adds API-side validation of GET method * feat: Adds API-side validation of POST and PUT request * feat: Adds logic to PUT request * feat: Adds preexisting player checks for POST request * chore: Cleans up error codes, and messages for apigateway * refactor: Removes an unnecessary dDBHandler client creation * feat: Adds timeout to playerHands PUT request
…nder feature flag) (#25324) When using `addMethod` with `requestValidatorOptions` it is not possible to do this multiple times on the same RestApi. The same node id is used for all `RequestValidators` added using this method. This PR adds a new feature flag which when enabled will generate a unique id for the RequestValidators added in this way. fixes #7613 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
|
Calling the constructor for RequestValidatorOptions multiple times gives an error
There is already a Construct with name 'validator' in RestApi
Reproduction Steps
`
`
Error Log
Environment
Other
This is 🐛 Bug Report
The text was updated successfully, but these errors were encountered: