Skip to content

fix(upgrade): avoid downgrading older dist-tags#17028

Open
farrosfr wants to merge 2 commits into
withastro:mainfrom
farrosfr:fix/17024-upgrade-beta-downgrade-clean
Open

fix(upgrade): avoid downgrading older dist-tags#17028
farrosfr wants to merge 2 commits into
withastro:mainfrom
farrosfr:fix/17024-upgrade-beta-downgrade-clean

Conversation

@farrosfr

Copy link
Copy Markdown
Contributor

Changes

  • Prevent @astrojs/upgrade from selecting a requested dist-tag when that tag resolves to a version older than the currently installed package.
  • Preserve prerelease comparison for installed versions like 7.0.0-beta.3 instead of coercing them to stable versions.
  • Add a regression test covering astro upgrading to beta while an integration remains on a newer stable release.

Why

Running @astrojs/upgrade beta could downgrade companion packages when their beta dist-tag pointed to an older prerelease than the currently installed stable version.

Fixes #17024

Testing

@changeset-bot

changeset-bot Bot commented Jun 10, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9242dcd

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@astrojs/upgrade Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@farrosfr
farrosfr force-pushed the fix/17024-upgrade-beta-downgrade-clean branch from b0d81c4 to 21c4963 Compare June 10, 2026 13:49
@farrosfr
farrosfr marked this pull request as ready for review June 10, 2026 14:07
@farrosfr
farrosfr force-pushed the fix/17024-upgrade-beta-downgrade-clean branch from 21c4963 to 5b7a903 Compare June 18, 2026 08:16
@farrosfr

farrosfr commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto latest main (was 146 commits behind, now 0 behind / 1 ahead — status: ahead instead of diverged, so mergeable_state should unblock once CI re-runs green). All 25 @astrojs/upgrade tests pass locally including the new does not downgrade packages when a requested tag points to an older version regression test.

The fix is still relevant: main's verify.ts still uses the bare semverCoerce(packageInfo.currentVersion)\! without the parseCurrentVersion helper, so the downgrade bug from #17024 persists. cc @ocavue since you own packages/upgrade/
Happy to adjust the approach or the test if you'd prefer a different shape.

@farrosfr
farrosfr force-pushed the fix/17024-upgrade-beta-downgrade-clean branch from 5b7a903 to 9242dcd Compare July 17, 2026 02:11
@kydecker

Copy link
Copy Markdown
Contributor

@farrosfr It appears the fix for this issue has already been merged and published in #17216

@farrosfr

Copy link
Copy Markdown
Contributor Author

Hi @kydecker Thanks for checking in.

While #17216 handles stable-version fallbacks, it misses when the current version is a newer prerelease (e.g. 7.0.0-beta.3) and the requested beta tag is older (e.g. 7.0.0-beta.2). On main, this falls back to latest (e.g. ^6.4.5), which still results in a downgrade.

This PR has been rebased and updated with a minimal fix and a unit test to prevent this prerelease-to-prerelease downgrade. Let me know what you think!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@astrojs/upgrade beta installation will downgrade packages to lower beta versions

2 participants