Skip to content

fix(cli): resolve command aliases in unknown options check#1536

Merged
sanjanaravikumar-az merged 4 commits into
mainfrom
sanjrkmr/fix-unknown-options-alias
May 20, 2026
Merged

fix(cli): resolve command aliases in unknown options check#1536
sanjanaravikumar-az merged 4 commits into
mainfrom
sanjrkmr/fix-unknown-options-alias

Conversation

@sanjanaravikumar-az
Copy link
Copy Markdown
Contributor

@sanjanaravikumar-az sanjanaravikumar-az commented May 20, 2026

Summary

  • Fixes regression where command aliases (e.g. cdk ls, cdk synthesize, cdk ack, cdk doc) incorrectly triggered unknown option warnings for their command-specific flags
  • Builds a reverse alias→canonical map at module scope and resolves the command before looking up options in the registry

Root Cause

findUnknownOptions used argv._[0] directly as the key into config.commands, but cli-type-registry.json only stores commands under their canonical names (list, synth, acknowledge, docs). When a user invokes via alias (ls, synthesize, ack, doc), the lookup returns undefined and 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

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
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 20, 2026

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.20%. Comparing base (afc83b7) to head (8bc6507).

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              
Flag Coverage Δ
suite.unit 88.20% <100.00%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@aws-cdk-automation aws-cdk-automation added this pull request to the merge queue May 20, 2026
@sanjanaravikumar-az sanjanaravikumar-az removed this pull request from the merge queue due to a manual request May 20, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants