Fix false success message when CLI self-upgrade installs the wrong version - #8473
Open
craigmichaelmartin wants to merge 1 commit into
Open
Fix false success message when CLI self-upgrade installs the wrong version#8473craigmichaelmartin wants to merge 1 commit into
craigmichaelmartin wants to merge 1 commit into
Conversation
The global upgrade path ran the package-manager install and then unconditionally rendered "Shopify CLI upgraded. You're now on version X", where X came from the cached public-registry version check. The install itself resolves through the user's configured registry, so a private registry with a stale `latest` tag could downgrade the CLI (e.g. 4.7.0 to 3.94.3) with a zero exit code while the CLI announced 4.7.1. Now the actually installed version is checked with globalCLIVersion() after the install: an older-than-expected or unverifiable result throws an AbortError pointing at registry misconfiguration, and the success banner reports the verified version. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Assisted-By: devx/8c611a3b-3427-4aaf-adf4-21fa91d61513
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.
WHY are these changes introduced?
A user behind a private npm registry ran the CLI self-update on 4.7.0: the registry (401ing against upstream) resolved a stale
latesttag, sonpm install -g @shopify/cli@latestdowngraded them to 3.94.3 with a zero exit code — while the CLI printed "Shopify CLI upgraded. You're now on version 4.7.1."Root cause:
runCLIUpgradebuilt the success banner from the cached version check (which queries the public npm registry) and trusted the install's exit code, but the install resolves through whatever registry the user's npm config points at. The two can disagree, and the exit code alone doesn't prove the right version landed.WHAT is this pull request doing?
In
packages/cli-kit/src/public/node/upgrade.ts, after the package-manager install completes, verify what was actually installed using the existingglobalCLIVersion()helper (runs the installedshopifybinary and parses its version):AbortErrornaming both versions, with a hint that the package manager may be resolving@shopify/clifrom a registry with outdated versions.AbortErrorsuggestingshopify version.The auto-upgrade postrun hook already catches errors from
runCLIUpgrade, so a failed background upgrade now logs, shows the upgrade reminder, recordsenv_auto_upgrade_success: false, and reports to Bugsnag instead of silently claiming success.Minor wording change:
shopify upgradewhen already up to date now says "You're now on version X." (the verified version) instead of "You're now on the latest version."How to test your changes?
pnpm vitest run src/public/node/upgrade.test.tsinpackages/cli-kit(new cases cover the downgrade, same-version, unverifiable, and verified-success paths).shopify upgradenormally — the success banner should show the actual installed version. To simulate the failure, point npm at a registry serving an older@shopify/cli(npm config set registry ...) and runshopify upgrade— it should abort with "Failed to upgrade Shopify CLI. Expected to be on version X, but version Y is now installed." instead of a success banner.Checklist
patchfor bug fixes ·minorfor new features ·majorfor breaking changes) and added a changeset withpnpm changeset add🤖 Generated with Claude Code