Skip to content

Prevent @astrojs/upgrade from downgrading packages when a dist-tag points to an older version#17216

Merged
matthewp merged 2 commits into
mainfrom
triagebot/fix-17024
Jun 26, 2026
Merged

Prevent @astrojs/upgrade from downgrading packages when a dist-tag points to an older version#17216
matthewp merged 2 commits into
mainfrom
triagebot/fix-17024

Conversation

@astrobot-houston

Copy link
Copy Markdown
Contributor

Changes

  • resolveTargetVersion() now compares the dist-tag version against the currently installed version before applying it. If the dist-tag resolves to an older version than what's installed, the function falls back to latest instead of downgrading.
  • Fixes the case where pnpm dlx @astrojs/upgrade beta would silently downgrade companion packages (e.g. @astrojs/sitemap from 3.7.33.6.1-beta.3) when their beta dist-tag pointed to a pre-release that predated the current stable.
  • resolveTargetVersion is now exported so it can be unit-tested directly.

Testing

  • Added describe('resolveTargetVersion') in packages/upgrade/test/verify.test.ts with three cases: no-downgrade when the beta dist-tag is older than the installed version; correct upgrade when the beta dist-tag is newer; and fallback to latest when the requested dist-tag doesn't exist on the registry.

Docs

  • No docs update needed; this is a bug fix for internal @astrojs/upgrade behavior with no API surface change.

Closes #17024

…\n\nWhen running , the resolveTargetVersion() function\nunconditionally used the version from the beta dist-tag without checking\nif it would be a downgrade from the currently installed version.\n\nThis caused packages like @astrojs/sitemap (3.7.3 → 3.6.1-beta.3) and\n@astrojs/rss (4.0.18 → 4.0.15-beta.4) to be downgraded.\n\nAdded a semver comparison that falls back to the dist-tag when\nthe requested dist-tag version is older than what's currently installed.
@changeset-bot

changeset-bot Bot commented Jun 26, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: c6c7c34

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@matthewp
matthewp merged commit d14b530 into main Jun 26, 2026
24 checks passed
@matthewp
matthewp deleted the triagebot/fix-17024 branch June 26, 2026 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix verified Reporter confirmed the triage bot fix works

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