Skip to content
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

chore(clients): parse numbers more strictly #2662

Merged
merged 3 commits into from
Aug 19, 2021

Conversation

JordonPhillips
Copy link
Member

Issue

n/a

Description

This provides methods to more strictly parse floats and ints. The strict float parser only allows explicit NaN and does not attempt to parse non-string, non-number values. The strict int parser disallows NaN entirely, and will opt to error if there are any decimals present. It also will not parse non-string, non-number values.

Testing

Unit tests were added for new methods. This also fixes a number of generated tests not released yet in Smithy.

Additional context

JS is very loose about what it will convert to a number, and we don't want to be nearly so loose, especially in the SSDK.

Related: smithy-lang/smithy-typescript#397


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@codecov-commenter
Copy link

codecov-commenter commented Aug 11, 2021

Codecov Report

❗ No coverage uploaded for pull request base (main@fac5f27). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2662   +/-   ##
=======================================
  Coverage        ?   60.73%           
=======================================
  Files           ?      521           
  Lines           ?    27833           
  Branches        ?     6847           
=======================================
  Hits            ?    16904           
  Misses          ?    10929           
  Partials        ?        0           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fac5f27...57e6cbe. Read the comment docs.

@aws-sdk-js-automation
Copy link

AWS CodeBuild CI Report

  • CodeBuild project: sdk-staging-test
  • Commit ID: 1f5dc34
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

packages/smithy-client/src/parse-utils.ts Outdated Show resolved Hide resolved
packages/smithy-client/src/parse-utils.spec.ts Outdated Show resolved Hide resolved
packages/smithy-client/src/parse-utils.spec.ts Outdated Show resolved Hide resolved
This provides methods to more strictly parse floats and ints. The
strict float parser only allows explicit NaN and does not attempt
to parse non-string, non-number values. The strict int parser
disallows NaN entirely, and will opt to error if there are any
decimals present. It also will noot parse non-string, non-number
values.
@trivikr trivikr changed the title chore: parse numbers more strictly chore(clients): parse numbers more strictly Aug 19, 2021
@trivikr trivikr merged commit 09715c8 into aws:main Aug 19, 2021
@github-actions
Copy link

github-actions bot commented Sep 3, 2021

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants