fix(cli): trap errors from notices to prevent CLI breakage#1205
Merged
aws-cdk-automation merged 2 commits intomainfrom Mar 6, 2026
Merged
fix(cli): trap errors from notices to prevent CLI breakage#1205aws-cdk-automation merged 2 commits intomainfrom
aws-cdk-automation merged 2 commits intomainfrom
Conversation
Extract a reusable `trapErrors` utility that swallows errors and logs them as debug messages. Use it for both `notices.refresh()` and `notices.display()` so that notice failures never break CLI execution.
rix0rrr
approved these changes
Mar 6, 2026
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.
In the past, a malformed notice payload caused the CLI to crash for users (see cdklabs/aws-cdk-notices#1044). The root cause was on the notices side and has been fixed, but the CLI should have never broken in the first place — notices are informational and must not affect CLI execution.
The
notices.refresh()call already had inline error handling, butnotices.display()did not. This meant that even after successfully fetching notices, a problem during display could still crash the CLI. The inline try/catch pattern is also easy to forget or get wrong when adding new call sites.This change introduces a
trapErrorsutility that encapsulates the "swallow and log as debug" pattern into a single reusable function. Bothnotices.refresh()andnotices.display()now use it, ensuring that notice-related failures can never break CLI execution going forward. While we cannot fix old CLI versions, we can make sure that future versions are resilient to this class of issues.The
noticescommand itself intentionally does not usetrapErrors— when a user explicitly runscdk notices, errors should surface loudly since that's the whole point of the command.Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license