Skip to content

Fix false success message when CLI self-upgrade installs the wrong version - #8473

Open
craigmichaelmartin wants to merge 1 commit into
mainfrom
craig/verify-installed-version-after-upgrade
Open

Fix false success message when CLI self-upgrade installs the wrong version#8473
craigmichaelmartin wants to merge 1 commit into
mainfrom
craig/verify-installed-version-after-upgrade

Conversation

@craigmichaelmartin

Copy link
Copy Markdown
Contributor

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 latest tag, so npm install -g @shopify/cli@latest downgraded 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: runCLIUpgrade built 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 existing globalCLIVersion() helper (runs the installed shopify binary and parses its version):

  • If the installed version is older than expected (the cached newer version, or the current version when none was cached), throw an AbortError naming both versions, with a hint that the package manager may be resolving @shopify/cli from a registry with outdated versions.
  • If the version can't be determined, throw an AbortError suggesting shopify version.
  • On success, the banner reports the verified installed version instead of the cached prediction.

The auto-upgrade postrun hook already catches errors from runCLIUpgrade, so a failed background upgrade now logs, shows the upgrade reminder, records env_auto_upgrade_success: false, and reports to Bugsnag instead of silently claiming success.

Minor wording change: shopify upgrade when 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?

  1. Unit tests: pnpm vitest run src/public/node/upgrade.test.ts in packages/cli-kit (new cases cover the downgrade, same-version, unverifiable, and verified-success paths).
  2. Manually: with a global install, run shopify upgrade normally — 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 run shopify 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

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes
  • I've considered analytics changes to measure impact
  • The change is user-facing — I've identified the correct bump type (patch for bug fixes · minor for new features · major for breaking changes) and added a changeset with pnpm changeset add

🤖 Generated with Claude Code

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
@github-actions github-actions Bot added the Area: @shopify/cli @shopify/cli package issues label Sep 3, 2026
@craigmichaelmartin
craigmichaelmartin marked this pull request as ready for review September 3, 2026 21:38
@craigmichaelmartin
craigmichaelmartin requested a review from a team as a code owner September 3, 2026 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: @shopify/cli @shopify/cli package issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant