Skip to content

fix(pm): require registry integrity for package-manager downloads that no pin covers - #3553

Merged
fengmk2 merged 6 commits into
mainfrom
fix/pm-tarball-only-mirror
Nov 23, 2026
Merged

fengmk2 merged 6 commits into
mainfrom
fix/pm-tarball-only-mirror

Conversation

@fengmk2

@fengmk2 fengmk2 commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Summary

#3547 checks unpinned package-manager downloads against the registry dist.integrity. When the version document omitted the field, the install continued without a check. When the version document returned 404, the install failed with PackageManagerVersionNotFound, even if the package document had the integrity.

This PR makes one rule: when no packageManager pin covers the files that vp runs, vp requires the registry dist.integrity. The rule applies to these downloads:

  • Unpinned installs of every package manager.
  • The platform package of Bun and pnpm 12+, with or without a pin. A pin for these two managers covers only the main tarball, which holds no executable.

Pinned npm, pnpm 11 and earlier, and Yarn installs do not change. They never fetch metadata.

Lookup

  1. vp reads the version document, <registry>/<name>/<version>.
  2. If that document returns 404 or omits dist.integrity, vp reads the abbreviated package document, <registry>/<name>. npm install reads the same document when no lockfile pins a package.
  3. If neither document gives the integrity, the install fails with PackageManagerIntegrityUnavailable before the download.
Registry response Before After
Version document has dist.integrity Verified Verified
Version document omits dist.integrity Installed without a check Verified with the package document
Version document 404 PackageManagerVersionNotFound Verified with the package document
Neither document gives dist.integrity Installed without a check, or PackageManagerVersionNotFound on a 404 PackageManagerIntegrityUnavailable, nothing downloaded
Package document does not list the version Not read PackageManagerVersionNotFound

On registry.npmjs.org, every version of npm, pnpm, yarn, @yarnpkg/cli-dist, and bun has dist.integrity, and so does every version of the Bun and pnpm platform packages that I sampled. So the first request succeeds there.

The new error

PackageManagerIntegrityUnavailable names the package and the package document URL, and gives a hint:

  • npm, pnpm 11 and earlier, and Yarn: add an integrity hash to the packageManager field, or use a registry that serves package metadata.
  • Bun and pnpm 12+: use a registry that serves package metadata. A pin does not help, because it does not cover the platform package.

Error::is_integrity_failure includes the new error. So a command that prepares a managed package manager stops with this error, and does not fall back to the package manager on PATH.

Closes #3554

One descriptor for each download

download_and_extract_tgz_with_hash_and_config took archive_file, expected_hash, and tarball_hash. expected_hash covered the archive or one entry, depending on archive_file. Without archive_file, the two hash parameters were the same check.

download_and_extract_tgz now takes a TgzDownload:

  • archive_digest always covers the .tgz bytes, and vp checks it before it reads any entry.
  • unpack is Unpack::All, or Unpack::Entry { path, digest }, where digest covers the extracted file only.

download_package_manager_inner selects both values in one place. Bun and pnpm 12+ share verify_pin_and_fetch_platform_integrity, which checks the pin against the main tarball and then fetches the platform integrity.

🤖 Generated with Claude Code

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview URL: https://fix-pm-tarball-only-mirror-viteplus-dev.voidzero-docs.workers.dev (commit b8f6a61)

This URL reflects your latest Preview deployment

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://394e8447-viteplus-dev.voidzero-docs.workers.dev b8f6a61 2026-11-23T13:51:07.682Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://1e786d60-viteplus-dev.voidzero-docs.workers.dev 3c6a035 2026-11-23T13:26:00.970Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://d08635f2-viteplus-dev.voidzero-docs.workers.dev 5f3ccb7 2026-11-23T12:48:22.219Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://5a988012-viteplus-dev.voidzero-docs.workers.dev 928bdc2 2026-11-23T12:28:23.899Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://ff0f5d37-viteplus-dev.voidzero-docs.workers.dev 020aa19 2026-11-23T11:43:23.376Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://44c1cd23-viteplus-dev.voidzero-docs.workers.dev 370f060 2026-11-23T11:22:04.940Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://89f00306-viteplus-dev.voidzero-docs.workers.dev a6ac80e 2026-11-23T08:12:42.649Z Visit the dashboard ↗

@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

CLI artifact sizes (b8f6a61)

Final release artifacts built by the canonical build-upstream and build-windows-cli actions.
The dist rows use the Linux build. The core total excludes .node files to match the release artifact.

Artifact Format Base PR Change
packages/cli/dist Directory total 2.38 MiB 2.38 MiB 0 B (0.00%)
packages/core/dist Directory total 4.11 MiB 4.11 MiB 0 B (0.00%)
Combined package dist Directory total 6.49 MiB 6.49 MiB 0 B (0.00%)
vp (Linux x64) Binary 8.56 MiB 8.57 MiB +8.05 KiB (+0.09%)
vp (Linux x64) gzip -9 3.92 MiB 3.92 MiB +897 B (+0.02%)
NAPI (Linux x64) Binary 37.29 MiB 37.31 MiB +16.13 KiB (+0.04%)
NAPI (Linux x64) gzip -9 14.91 MiB 14.91 MiB +2.36 KiB (+0.02%)
vp (macOS ARM64) Binary 5.61 MiB 5.61 MiB +80 B (+0.00%)
vp (macOS ARM64) gzip -9 3.34 MiB 3.35 MiB +3.61 KiB (+0.11%)
NAPI (macOS ARM64) Binary 43.83 MiB 43.83 MiB +32 B (+0.00%)
NAPI (macOS ARM64) gzip -9 19.03 MiB 19.03 MiB +1.52 KiB (+0.01%)
vp (Windows x64) Binary 6.64 MiB 6.65 MiB +9.50 KiB (+0.14%)
vp (Windows x64) gzip -9 3.03 MiB 3.03 MiB +2.59 KiB (+0.08%)
NAPI (Windows x64) Binary 33.24 MiB 33.25 MiB +9.00 KiB (+0.03%)
NAPI (Windows x64) gzip -9 13.63 MiB 13.64 MiB +5.28 KiB (+0.04%)
Trampoline (Windows x64) Binary 13.50 KiB 13.50 KiB 0 B (0.00%)
Trampoline (Windows x64) gzip -9 7.09 KiB 7.09 KiB 0 B (0.00%)
Installer (Windows x64) Binary 4.69 MiB 4.69 MiB +7.50 KiB (+0.16%)
Installer (Windows x64) gzip -9 2.25 MiB 2.25 MiB +3.75 KiB (+0.16%)

@fengmk2
fengmk2 marked this pull request as ready for review November 23, 2026 08:31
@fengmk2 fengmk2 self-assigned this Nov 23, 2026
@fengmk2
fengmk2 requested review from cpojer and jong-kyung November 23, 2026 08:31
@fengmk2
fengmk2 force-pushed the fix/pm-tarball-only-mirror branch from 370f060 to 020aa19 Compare November 23, 2026 11:42
@fengmk2 fengmk2 changed the title fix(pm): keep tarball-only mirrors working for unpinned package managers fix(pm): require registry integrity for package-manager downloads that no pin covers Nov 23, 2026
@fengmk2 fengmk2 added test: e2e Auto run e2e tests test: install-e2e run vite install e2e test test: create-e2e Run `vp create` e2e tests labels Nov 23, 2026
@fengmk2
fengmk2 force-pushed the fix/pm-tarball-only-mirror branch from 5f3ccb7 to 3c6a035 Compare November 23, 2026 13:25
fengmk2 and others added 6 commits November 23, 2026 21:48
An unpinned install fetches the version document for `dist.integrity`.
When that document returned 404, the install failed even when the
tarball existed. A 404 now has the same result as a document that omits
`dist.integrity`: the install continues without the registry check and
vp logs it at debug level. A missing version still fails with
`PackageManagerVersionNotFound` from the tarball request.

Replace the three hash-related parameters of the tgz download helper
with a `TgzDownload` descriptor. `archive_digest` always covers the
`.tgz` bytes, and `Unpack::Entry { digest }` covers the extracted file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A Bun or pnpm 12+ pin covers only the main tarball, so the registry
integrity is the only check of the platform executable. When the
registry did not serve the platform version document, a pinned install
continued without that check and added the executable to the verified
namespace. Let callers choose the 404 policy: unpinned installs
continue, and pinned native installs keep the error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Move the main-tarball pin check and the platform integrity fetch of Bun
and pnpm 12+ into `verify_pin_and_fetch_platform_integrity`, so the rule
that a pin covers only the main tarball lives in one place.

Merge the unpinned registry integrity tests into one table, share the
native platform fixtures, and run the single-entry digest cases without
the retry delays.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A version document that omits `dist.integrity` still installs the
platform executable without the check, as #3554 tracks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An unpinned download, and the platform package of Bun or pnpm 12+, now
need the registry `dist.integrity`. vp reads the version document first,
then the abbreviated package document when the version document is
missing or omits the field. When neither gives it, the install fails
with `PackageManagerIntegrityUnavailable` before the download, and the
error tells the user how to fix it. A pinned npm, pnpm 11 and earlier,
or Yarn install still never fetches metadata.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Make `RegistryPackument` generic over the version metadata, so the
integrity lookup and the version list read one struct. Share the
version-document mock between the test helpers, narrow an integrity
parameter that is never `None`, and drop a slow test case that other
cases already cover.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fengmk2
fengmk2 force-pushed the fix/pm-tarball-only-mirror branch from 3c6a035 to b8f6a61 Compare November 23, 2026 13:50
@fengmk2
fengmk2 merged commit 5ccfbb3 into main Nov 23, 2026
150 checks passed
@fengmk2
fengmk2 deleted the fix/pm-tarball-only-mirror branch November 23, 2026 14:08
@fengmk2 fengmk2 mentioned this pull request Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test: create-e2e Run `vp create` e2e tests test: e2e Auto run e2e tests test: install-e2e run vite install e2e test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pinned Bun and pnpm 12+ installs cache an unchecked executable when the registry omits dist.integrity

3 participants