fix(cli): resolve command aliases in unknown options check#1536
Merged
Conversation
When a user runs a command via its alias (e.g. `cdk ls` instead of `cdk list`), argv._[0] contains the alias string. The unknown options check was using this directly as the key into config.commands, which only has canonical command names. This caused all command-specific options to be incorrectly flagged as unknown. Build a reverse alias map at module scope and resolve to the canonical command name before looking up command options. Closes #1535
Contributor
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1536 +/- ##
==========================================
- Coverage 88.22% 88.20% -0.03%
==========================================
Files 76 76
Lines 10820 10834 +14
Branches 1488 1492 +4
==========================================
+ Hits 9546 9556 +10
- Misses 1246 1250 +4
Partials 28 28
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…heck Yargs stores positional args under both their original case (e.g. "ID") and lowercase (e.g. "id") in argv. The previous check only compared against the raw name from the registry, missing the other variant.
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
cdk ls,cdk synthesize,cdk ack,cdk doc) incorrectly triggered unknown option warnings for their command-specific flagsRoot Cause
findUnknownOptionsusedargv._[0]directly as the key intoconfig.commands, butcli-type-registry.jsononly stores commands under their canonical names (list,synth,acknowledge,docs). When a user invokes via alias (ls,synthesize,ack,doc), the lookup returnsundefinedand all command-specific options get flagged as unknown.Fix for PR: #1514
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license