Skip to content

fix(aws-cdk): use recommended value for a single unconfigured flag - #2050

Open
FOWEPJF255 wants to merge 1 commit into
aws:mainfrom
FOWEPJF255:fix/flags-unconfigured-single-recommended
Open

FOWEPJF255 wants to merge 1 commit into
aws:mainfrom
FOWEPJF255:fix/flags-unconfigured-single-recommended

Conversation

@FOWEPJF255

Copy link
Copy Markdown

Fixes #2048

Reason for this change

When exactly one feature flag is unconfigured, modifyValues takes the manual single-flag branch even though --value was not provided. It interprets undefined as false, so cdk.json receives false after the preview displayed the recommended value true.

Description of changes

Use the manual single-flag branch only when params.value is defined. This keeps the write behavior aligned with buildUpdateObject and preserves explicit single-flag values. Add a regression test for one unconfigured flag whose recommended value is true.

No dependency or IAM permission changes are included.

Validation

  • Red/green regression: before the fix, the preview showed true while cdk.json received false; after the fix, the test passes.
  • corepack yarn@4.17.1 jest --config jest.config.json --runInBand test/commands/flag-operations.test.ts --coverage=false — 59 tests passed.
  • corepack yarn@4.17.1 nx run aws-cdk:compile — passed for aws-cdk and its 9 compile dependencies.
  • ESLint on both changed files passed in the repository's eslintrc compatibility mode.
  • git diff --check and strict UTF-8 validation passed.

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

@maintainer-for-aws

Copy link
Copy Markdown

Automated review

A maintainer will still review this — treat the notes below as a starting point.

📌 Commit 837f667

This PR fixes a one-line logic bug in the experimental cdk flags command: when exactly one unconfigured boolean feature flag remained, cdk flags --set --unconfigured --recommended previewed the correct recommended value but wrote the wrong one to cdk.json. The fix adds params.value !== undefined to the single-flag guard in FlagOperations.modifyValues, so the manual --value branch only applies when a value was explicitly supplied; the --unconfigured single-flag case now falls through to the branch that writes flag.recommendedValue, matching the preview logic in the sibling buildUpdateObject. A targeted regression test reproduces the original scenario and asserts the correct persisted value. The change is minimal, well-scoped, and confirmed against the source. No issues found on this change.

🔴 0 blocking · 🟡 0 recommended · ⚪ 0 optional


Generated automatically. React 👍 or 👎 to tell us whether this review helped, so we can improve these reviews.

This branch is waiting to be deployed

1 inactive and 1 waiting deployments
integ-approval — 837f667a Waiting Oct 16, 2026 by FOWEPJF255 via prepare #7188
automation — 837f667a Deployed Oct 16, 2026 by FOWEPJF255 via Triage Pull Requests #2203
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(flags): cdk flags --set --unconfigured --recommended writes false when exactly one flag is unconfigured

3 participants