Skip to content

fix(cli): trap errors from notices to prevent CLI breakage#1205

Merged
aws-cdk-automation merged 2 commits intomainfrom
mrgrain/fix/notices-shall-not-break
Mar 6, 2026
Merged

fix(cli): trap errors from notices to prevent CLI breakage#1205
aws-cdk-automation merged 2 commits intomainfrom
mrgrain/fix/notices-shall-not-break

Conversation

@mrgrain
Copy link
Copy Markdown
Contributor

@mrgrain mrgrain commented Mar 6, 2026

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, but notices.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 trapErrors utility that encapsulates the "swallow and log as debug" pattern into a single reusable function. Both notices.refresh() and notices.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 notices command itself intentionally does not use trapErrors — when a user explicitly runs cdk notices, errors should surface loudly since that's the whole point of the command.

Checklist

  • This change contains a major version upgrade for a dependency and I confirm all breaking changes are addressed
    • Release notes for the new version:

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

mrgrain added 2 commits March 6, 2026 17:43
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.
@aws-cdk-automation aws-cdk-automation added this pull request to the merge queue Mar 6, 2026
Merged via the queue into main with commit 1cb6252 Mar 6, 2026
50 of 51 checks passed
@aws-cdk-automation aws-cdk-automation deleted the mrgrain/fix/notices-shall-not-break branch March 6, 2026 18:41
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.

3 participants