Skip to content

fix(aws-cdk): scope --json to commands that honor it - #2068

Open
Mr-Perfectuz wants to merge 1 commit into
aws:mainfrom
Mr-Perfectuz:fix/json-option-scope-1695
Open

Mr-Perfectuz wants to merge 1 commit into
aws:mainfrom
Mr-Perfectuz:fix/json-option-scope-1695

Conversation

@Mr-Perfectuz

Copy link
Copy Markdown

Fixes #1695

Reason for this change

--json / -j was registered as a global CLI option, so every command accepted it even though only context, list/ls, bootstrap, synth/synthesize, and metadata actually use it. On other commands the flag was a silent no-op, which is misleading for machine-readable workflows.

Description of changes

  • Move --json from global options in cli-config.ts onto the five commands that honor it
  • Regenerate yargs / UserInput / convert helpers via user-input-gen
  • Update unknown-option detection expectations so unsupported commands report --json
  • Add unit coverage for command-scoped parsing and cdk.json conversion

Behavioral notes:

  • Supported usage remains cdk <command> --json (or -j)
  • Unsupported commands (e.g. cdk deploy --json) now emit the existing unknown-option warning instead of being silently ignored
  • cdk --json <command> no longer works, because --json is no longer global; put the flag after the command

No dependency or IAM permission changes are included.

Validation

  • Regenerated CLI parser/types from cli-config.ts via scripts/user-input-gen.ts
  • yarn compile in packages/aws-cdk
  • Unit tests: cli-arguments.test.ts (16 passed) and check-unknown-options.test.ts (23 passed)

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

Move --json off the global option list so unsupported commands warn
instead of silently ignoring it. Fixes aws#1695.

Co-authored-by: Cursor <cursoragent@cursor.com>

This branch is waiting to be deployed

1 failed and 1 waiting deployments
integ-approval — 0736650b Waiting Oct 21, 2026 by Mr-Perfectuz via prepare #7313
automation — 0736650b Deployed Oct 21, 2026 by Mr-Perfectuz via Triage Pull Requests #2225
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.

(cli): --json is a global option but is silently ignored by most commands

1 participant