Repository navigation
fix: report a failed update check from the upgrade command - #808
Conversation
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #808 +/- ##
==========================================
+ Coverage 80.00% 80.20% +0.20%
==========================================
Files 244 244
Lines 18730 18736 +6
==========================================
+ Hits 14984 15027 +43
+ Misses 3746 3709 -37 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| } | ||
| checkErr := updateNotification.CheckForUpdate(ctx, true) | ||
|
|
||
| // Print the updates that were found before returning an error from another check |
There was a problem hiding this comment.
praise: Printing the found updates before returning the hook error is a nice touch, so a broken check-update hook can never hide a CLI update.
WilliamBergamin
left a comment
There was a problem hiding this comment.
💯 Thanks @zimeg! Surfacing the offline failure from slack upgrade while keeping background checks quiet is exactly the right split, and the tests prove both sides.
Left a few comments, nothing blocking 🙏
| require.NoError(t, err) | ||
| } | ||
| if !tc.unreachable { | ||
| assert.Equal(t, int32(1), requests.Load()) |
There was a problem hiding this comment.
💯 praise: Asserting one request on the background case proves the check ran and the error was swallowed, not that the check was skipped.
| if err := updateNotification.PrintAndPromptUpdates(cmd); err != nil { | ||
| return err | ||
| } | ||
| if checkErr != nil { |
There was a problem hiding this comment.
💯 praise: Printing found updates before returning the check error means a failing check-update hook can't hide a CLI update, and the test covers it.
Co-authored-by: William Bergamin <25348381+WilliamBergamin@users.noreply.github.com> Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
|
🌟 Thanks for the kind reviews @mwbrooks and @WilliamBergamin! |
Changelog
The
slack upgradecommand now shows an error when it can't check for updates, such as while offline, instead of reporting that the latest version is installed.Summary
This pull request returns update check errors from the
slack upgradecommand instead of reporting the latest version.slack upgradeprinted "✔ You are using the latest Slack CLI version" and exited 0. A developer on an old version could believe they were current.slack upgrade) now returns the first dependency error. The Slack CLI check error is wrapped with a newcli_update_check_errorcode, with a suggestion to check the network or download the latest version.slack upgradeprints any updates it found before returning an error, so a failingcheck-updatehook in a project can't hide a Slack CLI update.MetadataURLis now a variable so tests can point it at anhttptestserver. It's exported because thecmd/upgradetests need it too, likecreate.GetSampleReposincmd/project.Preview
Before (exit 0)
After (exit 1)
Testing
With a build of this branch and an empty config folder (
mkdir -p /tmp/fix-check):HTTPS_PROXY=http://127.0.0.1:9 ./bin/slack upgrade --config-dir /tmp/fix-checkprints the error above and exits 1. Onmainit prints "✔ You are using the latest Slack CLI version" and exits 0.HTTPS_PROXY=http://127.0.0.1:9 ./bin/slack auth list --config-dir /tmp/fix-checkwith nolast_update_checked_at(so the background check runs) prints "You are not logged in to any Slack accounts" and exits 0, with no update error../bin/slack upgrade --config-dir /tmp/fix-checkwhile online still prints "✔ You are using the latest Slack CLI version" and exits 0.Notes
check-updatehook now also makesslack upgradeerror, after printing any updates that were found. Before, that error was only in the debug log.last_update_checked_at, so the next background check waits 24 hours. fix: retry a failed update check sooner #809, stacked on this one, retries sooner.Test_UpdateNotification_CheckForUpdate(a forced check returns the error on a 500 or an unreachable server, and a background check doesn't) andTest_checkForUpdates(the upgrade command returns the check error, returns thecheck-updatehook error, and prints an update before the hook error). Each fails without the change it covers.Requirements
🤖 Generated with Claude Code