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

cli: plugin option set in cdk.json is ignored #32814

Closed
1 task
wiget opened this issue Jan 9, 2025 · 3 comments · Fixed by #33107
Closed
1 task

cli: plugin option set in cdk.json is ignored #32814

wiget opened this issue Jan 9, 2025 · 3 comments · Fixed by #33107
Assignees
Labels
@aws-cdk/core Related to core CDK functionality bug This issue is a bug. effort/small Small work item – less than a day of effort p1 package/tools Related to AWS CDK Tools or CLI

Comments

@wiget
Copy link

wiget commented Jan 9, 2025

Describe the bug

The plugin option in the project's cdk.json file is ignored.

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Version

2.173.4

Expected Behavior

The plugin option in the project's cdk.json file is honoured and defined plugins are used to obtain credentials.

Current Behavior

The plugin option in the project's cdk.json file is ignored.

Reproduction Steps

npx cdk init app --language=typescript --generate-only
jq '. += {"plugin": ["dummy"]}' < cdk.json > edited-cdk.json
mv edited-cdk.json cdk.json
npx cdk --debug -vvv --no-color version

In the output, there will be merged settings section. Look for plugin. If it's [] then the bug is present.

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.174.0

Framework Version

No response

Node.js Version

22.11.0

OS

Ubuntu 24.04

Language

TypeScript

Language Version

Typescript (5.7.2)

Other information

No response

@wiget wiget added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jan 9, 2025
@github-actions github-actions bot added the package/tools Related to AWS CDK Tools or CLI label Jan 9, 2025
@kaizencc kaizencc self-assigned this Jan 9, 2025
@khushail khushail added p1 @aws-cdk/core Related to core CDK functionality effort/small Small work item – less than a day of effort and removed needs-triage This issue or PR still needs to be triaged. labels Jan 9, 2025
@brander-john
Copy link

In case this helps, looks like it was introduced here -> https://github.com/aws/aws-cdk/pull/32596/files#r1896971697

When the settings are merged due to the order of operations the default value [] for plugins in this.commandLineArguments overwrites any previous set value.

https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk/lib/settings.ts#L146-L151
https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk/lib/util/objects.ts#L110-L111

@khushail
Copy link
Contributor

Hi @wiget , thanks for reaching out. Looks like this has already been added to the core team's backlog and team should be working on it.

@mergify mergify bot closed this as completed in #33107 Jan 24, 2025
mergify bot pushed a commit that referenced this issue Jan 24, 2025
### Issue # (if applicable)

Closes #32814

### Reason for this change

yargs treats arrays weirdly. setting `default: undefined` results in the default array as `['undefined']`. So instead, I set the default to be `default: []`. However, this triggers an issue with the order of combining all arguments, and the CLI default was overriding any values in `cdk.json` for array types. So instead, we must omit the `default` property entirely for arrays, in order to achieve the desired behavior of `undefined` as default.

### Description of changes

Updated code generation to generate NO default property for array types

### Description of how you validated changes

tests in `user-input-gen` and the diff of `parse-command-line-arguments.ts` show that unless already defined, we are omitting defaults for arrays

### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

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

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
@aws-cdk/core Related to core CDK functionality bug This issue is a bug. effort/small Small work item – less than a day of effort p1 package/tools Related to AWS CDK Tools or CLI
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants