Skip to content

fix(aws-apigateway): api gateway usage plan#19023

Merged
mergify[bot] merged 6 commits intoaws:masterfrom
HariboDev:master
Feb 24, 2022
Merged

fix(aws-apigateway): api gateway usage plan#19023
mergify[bot] merged 6 commits intoaws:masterfrom
HariboDev:master

Conversation

@HariboDev
Copy link
Copy Markdown
Contributor

@HariboDev HariboDev commented Feb 17, 2022

API Gateway allows decimals and integers for rate limits. This PR fixes an error thrown when entering a decimal.

To fix this, I created a new method validateDouble() in utils.ts based off validateInteger() and updated the caller as seen in the commit.

This also fixes #18994.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@gitpod-io
Copy link
Copy Markdown

gitpod-io bot commented Feb 17, 2022

@github-actions github-actions bot added the @aws-cdk/aws-apigateway Related to Amazon API Gateway label Feb 17, 2022
Copy link
Copy Markdown
Contributor

@peterwoodworth peterwoodworth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution @HariboDev,

While this looks like it works great, I'm a little doubtful that the validateDouble method you've created is necessary. I imagine the purpose of the validateInteger method was to protect specifically against doubles, since typing should prevent any non-numbers from showing up in the first place.

What do you think?

@HariboDev
Copy link
Copy Markdown
Contributor Author

HariboDev commented Feb 19, 2022

Hi @peterwoodworth

I added this method as the original validateInteger method checks if the value is an integer by throwing an error when the value is not an integer via !Number.isInteger(property). Since rate limits allow for integer or decimal values, the validateInteger method would throw an error if a double is passed to it so I created the validateDouble method to:

  1. Check if value is valid number via isNaN(property)
  2. Check if value can be parsed as float and is still a valid number via isNaN(parseFloat(property))

I think both methods are needed as, according to the documentation, burst limits must be integers and rate limits can be either decimals or integers.

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Feb 24, 2022

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: e14905d
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit 5b764cc into aws:master Feb 24, 2022
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Feb 24, 2022

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

@aws-cdk/aws-apigateway Related to Amazon API Gateway

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(aws-apigateway): cannot set usage plan throttle rate limit to decimal value

4 participants