-
Notifications
You must be signed in to change notification settings - Fork 60
fix(cli): cdk notices ignores failures and calling cli with --no-notices makes an unexpected network call
#399
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
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #399 +/- ##
==========================================
- Coverage 79.25% 79.17% -0.08%
==========================================
Files 54 54
Lines 6897 6910 +13
Branches 772 773 +1
==========================================
+ Hits 5466 5471 +5
- Misses 1413 1421 +8
Partials 18 18
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:
|
If this prevents the CLI from running in those environments we have even more problems, because the behavior should be that failures get swallowed. This is not critical but best-effort behavior, so it's fine. It's just for |
Ah yes, you are correct. |
We could make a distinction in the internal state between "successful fetch with no notices" and "no fetch", and do something like: notices.assertLastFetchSuccessful();In the handling of |
dcd0105 to
5122208
Compare
6cfb393 to
e88e326
Compare
No code changes. This is in preparation of #399 to make the diff more manageable. --- By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license
a057085 to
4eaebec
Compare
cdk notices ignores failure fetching notices and calling cli with --no-notices makes an unexpected network call
cdk notices ignores failure fetching notices and calling cli with --no-notices makes an unexpected network callcdk notices ignores failures and calling cli with --no-notices makes an unexpected network call
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this file I mostly make the error messages consistent. Variations of Failed to fetch notices are moved to one level up. Any errors from this file will show up as the cause printed in yellow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AI generated. Needed an easy way to make errors more human.
| const refreshNotices = (async () => { | ||
| if (shouldDisplayNotices) { | ||
| try { | ||
| return await notices.refresh(); | ||
| } catch (e: any) { | ||
| await ioHelper.notify(IO.DEFAULT_TOOLKIT_DEBUG.msg(`Could not refresh notices: ${e}`)); | ||
| } | ||
| } | ||
| })(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refresh now throws
| const cause = ensureError(err.cause); | ||
| console.error(chalk.yellow(cause.message)); | ||
| printTrace(err, debug); | ||
| printTrace(cause, debug); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated bug, but previously in dev mode we would print the stack trace of the parent error twice.
4eaebec to
70eab93
Compare
Fixes #370
Fixes #440
Previously when the
--no-noticesoption was passed, the CLI would still attempt to refresh notices in the background. This is unnecessary and an unexpected behavior to users, especially when running the CLI in environments with no internet access.On the other hand, running the explicit
cdk noticescommand did previously not fail if the command failed to refresh notices. Instead the command would pretend no notices are found and complete successfully.This PR updates the code to not refresh notices when notices are disabled. Unless the explicit
cdk noticescommand is called, which will always refresh and now error if fetching notices fails. It also removes a double refresh of the notices (which didn't have an effect because they were cached, but still).cdk noticeswith an error now looks like this:Before the command would incorrectly and silently succeed and not show any notices:
Only when run with the
-vflag, it would hint at the failure:By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license