-
Notifications
You must be signed in to change notification settings - Fork 87
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
Fix Yargs parsing strings as numbers #2237
Conversation
Signed-off-by: Andrew W. Harn <[email protected]>
The reason we took this approach was because of a regression observed if we passed numbers to Yargs as number typed options. If a user supplied an option that took a number and provided no value That is because yargs returns This behavior would be a regression with no easy fix. In this implementation, we continue to treat numerics as a string until validation is done to confirm the option was not specified with an empty value (""), and the value provided is numeric. Once that validation is completed, the value of the argument is converted from string to number. Because we disabled the default yargs behavior to convert strings to numbers, we explicitly do the conversion when the option type is a number. Otherwise, it remains a string. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## next #2237 +/- ##
==========================================
+ Coverage 91.20% 91.22% +0.01%
==========================================
Files 632 632
Lines 18134 18142 +8
Branches 3848 3887 +39
==========================================
+ Hits 16540 16550 +10
+ Misses 1593 1591 -2
Partials 1 1 ☔ View full report in Codecov by Sentry. |
Looks good, but is it safe for us to assume that all numeric values will be integers? |
Signed-off-by: Andrew W. Harn <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @awharn!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @awharn for the fix!
Signed-off-by: Andrew W. Harn <[email protected]>
Signed-off-by: Andrew W. Harn <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @awharn
Signed-off-by: Andrew W. Harn <[email protected]>
Signed-off-by: Andrew W. Harn <[email protected]>
Found a small bug - the change was not converting the values assigned to the alternate option names (aliases and camel case) to numbers, which caused system tests to fail for creating data-sets. Regression tests added, and changed the implementation to use the Re-requested reviews from all reviewers. |
Signed-off-by: Andrew W. Harn <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @awharn for updating this to handle aliases too! 😋
Quality Gate passedIssues Measures |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes LGTM! 😋
What It Does
Prevents parsing string arguments as numbers if the value provided only consists of numerics.
Resolves #1881
How to Test
Run the
zowe files download ds "FAKE.DS" --rto 50 --encoding 1047 --show-inputs-only
command and observe the response timeout is blue (number) and encoding is white (string).Review Checklist
I certify that I have:
Additional Comments