Skip to content

Respect exact version argument in @astrojs/upgrade - #18466

Merged
matthewp merged 2 commits into
mainfrom
factory/fix-18420
Oct 20, 2026
Merged

matthewp merged 2 commits into
mainfrom
factory/fix-18420

Conversation

@astro-factory

@astro-factory astro-factory Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Changes

  • @astrojs/upgrade [version] now pins packages to the requested exact version instead of silently falling back to latest. resolveTargetVersion() previously only checked the argument against npm dist-tags; an exact semver like 7.3.8 never matched, so the CLI always resolved to latest with no warning.
  • The fix consults the versions map already present in the npm metadata. If the argument is a published version of a package, that version is used with no ^. Packages that never published that version (e.g. @astrojs/* integrations with their own version schemes) still fall back to ^latest, preserving existing behaviour.

Testing

  • New test cases added to packages/upgrade/test/verify.test.ts covering: exact version resolves correctly, unknown version falls back to latest, and dist-tag arguments continue to work.

Docs

  • No docs update needed; the [version] parameter was already advertised in the CLI help text — the fix makes the implementation match the documented behaviour.

Closes #18420

@astro-factory astro-factory Bot added the fix verified Reporter confirmed the triage bot fix works label Oct 20, 2026
@changeset-bot

changeset-bot Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e8c3618

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

@astro-factory

astro-factory Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor Author

astro-author owns this pull request

Factory's code author persona works on this branch when a maintainer or Factory's reviewer requests changes, or when checks fail: it pushes follow-up commits, replies to review threads, and asks for another review. It never merges. Unassign astro-author to take the pull request back; reassign it to start a fresh budget.

Rounds used: 1 of 5
Status: waiting for feedback.

— astro-author (Factory persona)

@astro-factory
astro-factory Bot removed the request for review from astro-reviewer October 20, 2026 17:20

@astro-factory astro-factory Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: changes requested.

GitHub doesn't let Factory request changes on a pull request it opened, so this verdict is recorded as a comment.

Findings

  • [high][correctness] packages/upgrade/src/actions/verify.ts:148: The exact-version branch uses Astro's version number for every @astrojs/* package that happens to have published the same string. This can downgrade independently versioned adapters and integrations to old, incompatible releases.

Merge Requirement Assessment

Status: gaps found

  • @astrojs/upgrade <exact version> pins astro to that version instead of falling back to latest: satisfied. resolveTargetVersion() now checks versions[targetVersion] and sets the target without a ^. The new uses an exact version when it is published test covers this.
  • Packages that never published that version still fall back to ^latest: satisfied. The falls back to latest when exact version is not published test covers this.
  • Integrations keep their existing behaviour: gap. Integrations that did publish a matching version number are pinned to it, even when that is far below the installed version. See the finding.

Review Status

Verdict: changes required
Context: PR #18466 and its description (closes #18420). I did not retrieve the linked issue's body.
Scope: PR base dda9ec3 to head af69ac3 (3 files).
Changeset: present and covers @astrojs/upgrade (patch).
Limitations: I only had read-only access to remote files. I could not check the linked issue's discussion or verkit's difference() semantics when the target version is lower than the installed one.
Validation: Static review only. I did not run any project code, tests, builds or checks.
GitHub context: collected
Git scope: PR base/head verified

This review was made by an LLM. The analysis may be wrong, and reports might be incorrect.

Comment thread packages/upgrade/src/actions/verify.ts Resolved
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ New Duplicate Dependencies (found: 6, threshold: 1)

📦 Package 📋 Versions
vitest
2 versions

[email protected]
find-up
4 versions
[email protected]

[email protected]
[email protected]
tinybench
2 versions

[email protected]
@vitest/spy
2 versions

@vitest/[email protected]
@vitest/mocker
2 versions

@vitest/[email protected]
why-is-node-running
2 versions

[email protected]

💡 To find out what depends on a specific package, run: pnpm -r why example-package

⚠️ Package Trust Level Decreased

Caution

Decreased trust levels may indicate a higher risk of supply chain attacks. Please review these changes carefully.

📦 Package 🔒 Before 🔓 After
@codspeed/core trustedPublisher provenance
@codspeed/vitest-plugin trustedPublisher provenance
tinybench stagedPublish none
tinyrainbow stagedPublish none
why-is-node-running provenance none

Integrations are versioned independently, so a published version string
matching the requested Astro version must not be used for them; they
keep the dist-tag/latest fallback instead of being downgraded.
@astro-factory

astro-factory Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

Round 1 of 5: applied the requested changes

Exact-version pinning now applies only to astro, since the version argument names an Astro release. @astrojs/* adapters and integrations have their own version numbers, so they keep the existing dist-tag/latest behaviour even when they happen to have published the same version string. That stops npx @astrojs/upgrade 6.0.0 from moving @astrojs/cloudflare@^12 back down to 6.0.0.

I added a regression test: @astrojs/cloudflare@^12.5.0 with target 6.0.0, where the registry lists 6.0.0, now resolves to ^12.6.0. Before I rebuilt the package, this test failed against the old build, which confirms it catches the bug.

Checks run:

  • pnpm -C packages/upgrade build
  • astro-scripts test "test/**/*.test.ts": all 31 tests pass.
  • biome check packages/upgrade: clean.
  • tsc --noEmit: clean.

Pushed e8c36182cf40.
Replied to 1 review thread(s), resolved 1.
Asked astro-reviewer to review again.

These changes were made by an LLM. They may be wrong; review them like any other contribution.
— astro-author (Factory persona)

@astro-factory
astro-factory Bot removed the request for review from astro-reviewer October 20, 2026 17:28

@astro-factory astro-factory Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: approved. No blocking findings remain.

GitHub doesn't let Factory approve a pull request it opened, so this verdict is recorded as a comment.

Findings

No findings.

Merge Requirement Assessment

Status: satisfied

  • @astrojs/upgrade <exact-version> pins astro to that published version instead of quietly resolving to latest. In resolveTargetVersion, when no dist-tag matches, the code now reads the versions map from the abbreviated npm metadata (install-v1+json includes versions). For astro, it uses the requested version with no ^. filterPackages and the install command then use this exact targetVersion. The new test uses an exact version when it is published covers this case.
  • Packages that never published the requested version still fall back to ^latest. Covered by falls back to latest when exact version is not published.
  • Integrations are versioned independently, so they are not pinned to an Astro version number even if they happen to publish one. The check is limited to packageInfo.name === 'astro', and does not pin integrations to an exact Astro version they happen to publish covers it. The PR body says "a published version of a package", but the code is narrower and limits exact pinning to astro. This is the safer reading of the intent, and the PR body says integrations should keep falling back to ^latest, which matches the code.
  • Dist-tag arguments behave as before. The existing dist-tag branch is unchanged (it is now the else if), and the existing dist-tag tests remain.

Review Status

Verdict: ready to merge based on static review
Context: PR #18466 plus PR description (the linked issue #18420 could not be retrieved with the available tools)
Scope: PR base dda9ec3 to head e8c3618, including packages/upgrade/src/actions/verify.ts, packages/upgrade/test/verify.test.ts, and .changeset/upgrade-exact-version.md.
Changeset: present and covers @astrojs/upgrade (patch).
Limitations: The text of linked issue #18420 was not available, so the requirements come from the PR description.
Validation: This was a static review only. No project code, tests, builds, or checks were run.
GitHub context: collected (PR metadata and diffs only)
Git scope: PR base and head verified through the GitHub tools.

This review was made by an LLM. The analysis may be wrong, and reports might be incorrect.

@matthewp
matthewp merged commit d7f5c54 into main Oct 20, 2026
25 checks passed
@matthewp
matthewp deleted the factory/fix-18420 branch October 20, 2026 18:03
@astrobot-houston astrobot-houston mentioned this pull request Oct 20, 2026
matthewp added a commit that referenced this pull request Oct 29, 2026
* Fix corrupted `astro:env/server` module when env vars contain `$` replacement patterns (#18330)

* [ci] format

* Fix inlined Vue styles in dev serving untransformed (unscoped, raw v-bind) CSS (#18336)

Co-authored-by: factory[bot] <factory[bot]@users.noreply.github.com>

* fix(deps): update vitest monorepo to v5 (#18403)

Co-authored-by: Florian Lefebvre <[email protected]>

* Update Partytown to 1.0.1 (#18439)

* fix(cloudflare): return 4xx instead of 500 from `/_image` when the source isn't an image (#18422)

Co-authored-by: Claude Opus 5.5 <[email protected]>

* Skip server island manifest in CSS ensureModulesLoaded to fix late-discovery 500 in dev (#18399)

Co-authored-by: factory[bot] <factory[bot]@users.noreply.github.com>

* Fix astro-check binary silently dropping the first two CLI arguments (#18455)

Co-authored-by: factory[bot] <factory[bot]@users.noreply.github.com>

* Preserve sharpImageService() options when imageService: 'compile' is used in the Cloudflare adapter (#18461)

Co-authored-by: factory[bot] <factory[bot]@users.noreply.github.com>

* fix(check): skip Volar's cancellation polling sleep in `astro check` (#18460)

Co-authored-by: factory[bot] <factory[bot]@users.noreply.github.com>

* fix(content): compute UTF-8 width arithmetically in getChunkEnd (#18430)

* fix(content): compute UTF-8 width arithmetically in getChunkEnd

* test(content): cover UTF-8 width boundaries and lone surrogates in chunkString

* chore: changeset

* fix(cloudflare): don't prebundle Astro in the Node prerender environment so a custom src/fetch.ts renders through the dev environment (#18465)

Co-authored-by: factory[bot] <factory[bot]@users.noreply.github.com>

* Respect exact version argument in @astrojs/upgrade (#18466)

* fix(upgrade): respect exact version argument in @astrojs/upgrade

* fix(upgrade): only pin exact version for the astro package

Integrations are versioned independently, so a published version string
matching the requested Astro version must not be used for them; they
keep the dist-tag/latest fallback instead of being downgraded.

---------

Co-authored-by: factory[bot] <factory[bot]@users.noreply.github.com>

* fix(i18n): use locale path instead of codes in defineConfig i18n types (#18467)

Co-authored-by: factory[bot] <factory[bot]@users.noreply.github.com>

* fix(cloudflare): skip Prism optimizeDeps include during type generation so sync/check/build don't overwrite a running dev server's deps_ssr (#18468)

Co-authored-by: factory[bot] <factory[bot]@users.noreply.github.com>

* Use a separate Vite cache for the temporary sync server (#18451)

`astro sync`, which `astro check` and `astro build` also run, starts a
temporary Vite server with `optimizeDeps: { noDiscovery: true }`. Astro
and integrations still add `optimizeDeps.include` entries, so Vite keeps
the dependency optimizer running there, and it wrote to the default
Vite cache. That replaced the optimized dependencies of a dev server
running in the same project, so framework islands in that dev server
broke (for example React's production `jsx-dev-runtime`, where `jsxDEV`
is undefined) until it was restarted with `--force`.

The temporary server now writes to `<cacheDir>/vite-sync/`. It optimizes
the same dependencies as before; only the output location changes.

Fixes #18449

Tested: `astro-sync.test.ts` passes 10/10; the new test fails without
the change in `sync/index.ts`.

* fix(dev): treat missing ps row as stale in lockfile process check (#18376)

Co-authored-by: Princesseuh <[email protected]>

* fix(astro): stop excluding node-fetch from server dep optimization in workerd dev (#18438)

Co-authored-by: factory[bot] <factory[bot]@users.noreply.github.com>

* Update dependency @playwright/test to v1.64.1 (#18441)

* Update @astrojs/node (#18440)

* Close duplicate pull requests when an issue is fixed (#18472)

* fix: minimal support node version (#18475)

* [ci] release (#18459)

* Fix release workflow package list after the Changesets v3 upgrade (#18104)

Co-authored-by: Chris Swithinbank <[email protected]>
Co-authored-by: Armand Philippot <[email protected]>

* Fix DataCloneError when importing SVGs with parallelPrerender enabled (#18476)

Co-authored-by: factory[bot] <factory[bot]@users.noreply.github.com>
Co-authored-by: Princesseuh <[email protected]>

* fix(telemetry): look up the project ID without blocking (#18481)

* Skip CSP hashes for external stylesheets and scripts. (#18488)

* [ci] format

* fix(astro): allow Node.js >=22.22.0 on StackBlitz WebContainers (#18494)

Co-authored-by: factory[bot] <factory[bot]@users.noreply.github.com>

* fix(assets): dedupe equivalent densities in image srcset (#18500)

Co-authored-by: factory[bot] <factory[bot]@users.noreply.github.com>

* docs: update legacy flags JSDocs to generate their reference in docs (#18378)

Co-authored-by: ematipico <[email protected]>

* Restore scroll position instantly on back/forward navigation when smooth scrolling is enabled (#18506)

Co-authored-by: factory[bot] <factory[bot]@users.noreply.github.com>

* fix(transitions): silence ready rejection before skipTransition in ClientRouter (#18517)

* Merge commit from fork

* ci: pass issue author login to needs-repro step via env (#18518)

* Restore CSS tree-shaking for unused barrel-imported Astro components (#18493)

* Mark $$createComponent pure so unused barrel-exported components drop their scoped CSS

* Bump Vite to 8.3.5 (Rolldown 1.2.15) and exercise the image service at runtime in the Sharp test

Rolldown 1.2.13 could fold its runtime helpers into a dynamically imported
page chunk, making the SSR entry statically import (and eagerly evaluate)
that page. Rolldown 1.2.14+ keeps the runtime out of entry chunks.

With unused components tree-shaken, the Cloudflare worker only bundles the
Sharp chain when an on-demand route uses the image service, so the Sharp
test now makes api.ts call getImage().

---------

Co-authored-by: factory[bot] <factory[bot]@users.noreply.github.com>
Co-authored-by: Matthew Phillips <[email protected]>

* Update @astrojs/markdoc (#18513)

* fix(@astrojs/vercel): make redirects match when trailingSlash is always/never (#18085)

* fix(@astrojs/vercel): make redirects match when trailingSlash is always/never

* refactor(@astrojs/vercel): use path slash utilities in adjustSourceForTrailingSlash

* fix(@astrojs/vercel): make spread redirects match under trailingSlash always

* fix(@astrojs/vercel): match Vercel's dot rule for trailing-slash redirects

Vercel's normalizer only appends a slash when the last segment has no dot,
so a dotted source must stay unslashed and a dynamic or spread last segment
has to match both forms. Verified against @vercel/routing-utils output.

* fix(@astrojs/vercel): avoid super-linear backtracking in dot check

eslint's regexp/no-super-linear-backtracking rejects the two overlapping
[^/]* quantifiers; anchoring on the last dot is equivalent and linear.

* fix(csp): include hashes inserted by body components in the CSP meta tag for non-streaming renders (#18512)

Co-authored-by: factory[bot] <factory[bot]@users.noreply.github.com>

* fix(server-islands): keep fallback instead of throwing when the island fetch fails (#18497)

Co-authored-by: factory[bot] <factory[bot]@users.noreply.github.com>

* fix(assets): avoid duplicate 1x candidate in Picture source srcset when densities includes 1 (#18504)

Co-authored-by: factory[bot] <factory[bot]@users.noreply.github.com>

* [ci] format

* fix(cloudflare): scope process.env define to server environments so client bundles get Vite's default replacement (#18526)

Co-authored-by: factory[bot] <factory[bot]@users.noreply.github.com>

* Fix type errors in shipped components under the `strictest` TypeScript preset (#18524)

* Fix strictest tsc errors in shipped Image, Picture, Code, Debug and ClientRouter components

* test(astro): type-check shipped components under strictest tsconfig

Add an astro check fixture whose tsconfig extends astro/tsconfigs/strictest
and includes node_modules/astro/components/*.astro, so the strictest errors
from #18471 cannot come back without CI failing.

---------

Co-authored-by: factory[bot] <factory[bot]@users.noreply.github.com>

* fix(cli): drop shell: true from astro info package manager calls to avoid DEP0190 warning (#18525)

Co-authored-by: factory[bot] <factory[bot]@users.noreply.github.com>

* Pass the React id prefix to `renderToString` when streaming is disabled (#18482)

* fix(react): pass identifierPrefix to renderToString when streaming is disabled

* test(react): give the disable-streaming fixture its own outDir

* Merge commit from fork

* Merge commit from fork

* Fix transition:name styles silently dropped in dev when component is nested under a non-propagating component (#18511)

Co-authored-by: factory[bot] <factory[bot]@users.noreply.github.com>

* Prevent memory cache from storing empty 404/500 responses that would be rerouted to error pages (#18522)

Co-authored-by: factory[bot] <factory[bot]@users.noreply.github.com>

* [ci] release (#18478)

* astro add: configure tagged official adapters (#18344)

Recognize resolved official package names when tagged specifiers are used so installation and Astro config updates stay aligned.

Co-authored-by: Matthew Phillips <[email protected]>

---------

Co-authored-by: Samuteg <[email protected]>
Co-authored-by: Samuteg <[email protected]>
Co-authored-by: astro-factory[bot] <316791938+astro-factory[bot]@users.noreply.github.com>
Co-authored-by: factory[bot] <factory[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Florian Lefebvre <[email protected]>
Co-authored-by: Jack Hanford <[email protected]>
Co-authored-by: Tim L. White <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Erika <[email protected]>
Co-authored-by: Abhirup Pal <[email protected]>
Co-authored-by: Denis Scarabelli <[email protected]>
Co-authored-by: okxint <[email protected]>
Co-authored-by: Emanuele Stoppa <[email protected]>
Co-authored-by: Houston (Bot) <[email protected]>
Co-authored-by: Chris Swithinbank <[email protected]>
Co-authored-by: Armand Philippot <[email protected]>
Co-authored-by: Muhammad Umer Aamir <[email protected]>
Co-authored-by: ematipico <[email protected]>
Co-authored-by: Nikolas Sapalidis <[email protected]>
Co-authored-by: knj <[email protected]>
Co-authored-by: Waleed Rostom 🐦‍⬛ <[email protected]>
Co-authored-by: Edmund Hung <[email protected]>
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 does not respect the [version] parameter

2 participants