fix: notices key in cdk.json is not respected#821
Merged
aws-cdk-automation merged 8 commits intomainfrom Sep 3, 2025
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #821 +/- ##
==========================================
- Coverage 82.82% 82.42% -0.41%
==========================================
Files 65 65
Lines 9509 9523 +14
Branches 1119 1109 -10
==========================================
- Hits 7876 7849 -27
- Misses 1599 1643 +44
+ Partials 34 31 -3
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:
|
iankhou
commented
Aug 28, 2025
packages/aws-cdk/lib/cli/cli.ts
Outdated
| const configNotices = configuration.settings.get(['notices']); | ||
| if (configNotices !== undefined) { | ||
| // Consider string "false" to be falsy in this context | ||
| shouldDisplayNotices = configNotices !== "false" && Boolean(configNotices); |
Contributor
Author
There was a problem hiding this comment.
Handle "false" as falsy.
Handle "", 0, null, and undefined as falsy.
iankhou
commented
Aug 28, 2025
Comment on lines
-61
to
-63
| export function shouldDisplayNotices(): boolean { | ||
| return !isCI() || Boolean(ciSystemIsStdErrSafe()); | ||
| } |
Contributor
Author
There was a problem hiding this comment.
Moved this logic to cli code.
Signed-off-by: github-actions <github-actions@github.com>
Signed-off-by: github-actions <github-actions@github.com>
rix0rrr
approved these changes
Sep 3, 2025
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.
Fixes #724
Description
Setting
"notices": falsein cdk.json doesn't suppress notices.The root cause is that we handle logic to determine whether we should print notices at yargs. Yargs had a default value determined by a helper function (
YARGS_HELPERS.shouldDisplayNotices()) that returned true when not in CI, or when in a safe CI.This meant that any setting in our configuration would be overwritten by the output of this helper, because it looks like it's coming from the command line!
Solution
Centralize logic for notices in
cli.ts.Made the notices option in yargs
undefinedby default. Moved the logic fromYARGS_HELPERS.shouldDisplayNotices()into thecli.ts. This has several implications.noticesin config now functions as expected; it will still not override the command line settingnotices: trueornotices: [truthy value]is set in config--noticesis passed, and NOT printed if--no-notices/--notices=falseis passed at the command line (was already the case)Caveat:
"notices": "false"in the config will suppress notices, but other "truthy" values will cause them to be printed.Testing
Added unit tests to verify the hierarchy of behavior:
--noticesor--no-notices)"notices": falsein cdk.json)By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license