Repository navigation
Fix false success message when CLI self-upgrade installs the wrong version - #8473
Merged
craigmichaelmartin merged 2 commits intoSep 9, 2026
Merged
Conversation
amcaplan
approved these changes
Sep 6, 2026
| vi.mocked(inferPackageManagerForGlobalCLI).mockReturnValue('npm') | ||
| vi.mocked(exec).mockResolvedValue() | ||
| vi.mocked(checkForCachedNewVersion).mockReturnValue('4.7.1') | ||
| vi.mocked(globalCLIVersion).mockResolvedValue('3.94.3') |
Contributor
There was a problem hiding this comment.
Might be slightly better to have a more subtly reduced version, like 4.7.0. But it's not a big deal either way - ultimately semver underlies this all anyway.
craigmichaelmartin
enabled auto-merge
September 8, 2026 12:42
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Sep 9, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Sep 9, 2026
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 <[email protected]> Assisted-By: devx/8c611a3b-3427-4aaf-adf4-21fa91d61513
craigmichaelmartin
force-pushed
the
craig/verify-installed-version-after-upgrade
branch
from
September 9, 2026 12:30
cea17b1 to
667c628
Compare
craigmichaelmartin
enabled auto-merge
September 9, 2026 12:34
The test mocked the expected version as a hardcoded '4.7.1' while mocking the installed version as the real CLI_KIT_VERSION. Since the check under test is semverLt(installedVersion, expectedVersion), it only reached the throw while CLI_KIT_VERSION stayed below 4.7.1. Release 4.8.0 pushed the constant past the literal, so the call resolved instead of rejecting. This never conflicted textually, so it surfaced only once the branch was built against main: the merge queue had been failing on it since 4.8.0 landed, while the branch's own CI still ran at 4.7.0 and stayed green. Derive the expected version from CLI_KIT_VERSION so the test keeps exercising the "install was a no-op" branch across future releases. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Assisted-By: devx/b0a16a56-5dc8-425b-b6b2-ed17d8d590d9
craigmichaelmartin
disabled auto-merge
September 9, 2026 13:35
craigmichaelmartin
enabled auto-merge
September 9, 2026 13:35
craigmichaelmartin
deleted the
craig/verify-installed-version-after-upgrade
branch
September 9, 2026 13:47
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