Skip to content

install: skip a registry manifest versions key that is not a version - #43115

Merged
Jarred-Sumner merged 2 commits into
robobun/ffab3bc7/install-no-assert-on-registry-datafrom
robobun/ac64d21b/install-skip-invalid-manifest-version-key
Sep 17, 2026
Merged

Jarred-Sumner merged 2 commits into
robobun/ffab3bc7/install-no-assert-on-registry-datafrom
robobun/ac64d21b/install-skip-invalid-manifest-version-key

Conversation

@robobun

@robobun robobun commented Sep 17, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #43117. Stacked on #43035. Review the last commit.

Problem

  • A registry manifest with one versions key that is not a version (such as 1.0.0.1) breaks each fresh resolve of that package. bun install, bun add and bun update print error: Failed to parse dependency 1.0.0.1, complete the install, and exit 1. bunx and bun create run bun add first, so they never run the binary. npm prints nothing and exits 0.
  • PackageManifest::parse (src/install/npm.rs:2127) logs the key as an error. run_tasks (src/install/PackageManager/runTasks.rs:1026) fails the command for any error in a task log. With a warm manifest cache the same install exits 0.

Fix

Background

  • A packument is the registry document for a package. versions maps each version string to that version's fields.
  • The parse runs in a thread pool task with its own log. run_tasks prints that log on the main thread.
  • The manifest disk cache stores the parsed manifest, so a cache hit skips the parse.
Notes

Origin. Review comment #43035 (comment) (marked pre-existing). #43035 removes the debug assertions on registry data and keeps the release behavior on purpose. This PR is the release behavior change, so it can be judged alone. If #43035 merges first, GitHub moves this PR to main. If #43035 is closed, this PR also needs its removal of the two debug_assert!(parsed_version.valid) lines, or a debug build stops on the assertion before it reaches this path.

Self-review. The first shape of this change branched from main. It repeated the two assertion removals of #43035 and added tests that contradicted the test #43035 pins. It is now one hunk on top of #43035, and it changes that test in place. The bug had no record outside of pull requests, so #43117 now tracks it. The symptom list was incomplete: the bunx, bun create, lockfile and bun publish facts below were added, each from a run.

Commands. One packument with the keys not-a-version and 1.0.0, a local Bun.serve registry, no manifest cache. Each row was run on release 1.4.3-canary (c6b7fcb) and on a debug build of this branch.

Command Release This branch
bun install prints the error, installs, exit 1 no message, exit 0
bun add evil prints the error, installs, exit 1 no message, exit 0
bun update prints the error, exit 1 no message, exit 0
bunx evil, bunx evil@latest, bunx evil@1.0.0 prints the error, exit 1, the binary does not run the binary runs, exit 0
bun create evil prints the error, exit 1, the binary does not run the binary runs, exit 0
bun outdated prints the error, exit 0 no message, exit 0
bun pm view evil no message, exit 0 (it never prints this log) same
npm install (11.16.0) no message, exit 0

When the manifest is not parsed. With a real cache directory, release bun exits 1 on the first install and 0 on the second install of the same project (node_modules and the lockfile removed between the runs). With an up-to-date lockfile, bun does not request the manifest, and the install exits 0, also with --frozen-lockfile. So the fault shows on a fresh resolve: no lockfile, a new dependency, bun add, bun update, bunx, bun create.

How such a key gets into a registry. bun publish sends the version field with no check. A local Verdaccio 6.0.0 accepts bun publish of 1.0.0 and of 1.0.0.1 for one package. Both publishes exit 0, and the packument lists both keys. bun install of 1.0.0 from a clean project then exits 1 with error: Failed to parse dependency 1.0.0.1 on release, and 0 on this branch. npm publish refuses the same package: npm error Invalid version: "1.0.0.1".

Keys that Version::parse rejects (each gave exit 1 before): not-a-version, the empty string, __proto__, latest, 1.0.0.1, a.b.c, 1.2.3.4-beta, -1.0.0, 1.-1.0, 1..0. It accepts loose forms such as 1, 1.0, v1.0.0, =1.0.0, 1.x, *, 01.02.03, so those keys never reach this path. #42458 makes it reject a number above u64::MAX. Such a key then takes this path. If #42458 lands first, that key starts to exit 1 until this PR lands.

A dependency on the skipped key still fails. With only the key 1.0.0.1 in the packument, "evil": "1.0.0.1" exits 1 with error: No version matching "1.0.0.1" found for specifier "evil" (but package exists). "evil": "not-a-version" exits 1 with error: Package "evil" with tag "not-a-version" not found, but package exists. Release prints the same errors after the extra message.

Why not an always-on warning. The message would show on each cold install of each consumer of the registry, and not on a warm one. The consumer cannot fix the registry. npm, the reference for this input, prints nothing. The Package name mismatch warning in this function (npm.rs:2078) reports odd registry data only with --verbose.

Why not remove the message. It is the only hint for a registry operator whose version does not resolve. With --verbose it keeps the position in the packument:

1 | st-tags":{"latest":"1.0.0"},"versions":{"not-a-version":{"name":"evil", ...
                                              ^
warn: Skipping version "not-a-version" of "evil": not a valid semver version
   at evil:1:59

Control characters. The old message wrote the key to the terminal as it came from the registry. A key with an escape sequence printed as raw ESC and BEL bytes. The new message goes through bun_fmt::quote. For the key ESC [31mred BEL it prints "\^[[31mred\^G".

Not in this PR. bun publish accepts a version that is not a version. #43120 tracks that.

Tests. bun bd test test/cli/install/bun-install.test.ts -t "unexpected shape" runs the describe block of #43035 with the 3 tests of this PR: bun install, bun add bar, and bun install --verbose, each against a packument with four invalid keys. In the whole file, 13 other tests clone from gitlab.com and bitbucket.org or fetch https://some.url. They fail in a sandbox with no access to those hosts, with and without this change.

Suites run on the debug build of this branch: bun-install.test.ts (245 pass, the 13 above fail), bun-install-registry.test.ts, bun-add.test.ts, bun-update.test.ts, bun-pm.test.ts, bun-info.test.ts, bun-pm-diff.test.ts, minimum-release-age.test.ts, bun-install-cpu-os.test.ts, bun-install-tarball-integrity.test.ts, bun-install-retry.test.ts.


no test proof · iteration 1 · platform-specific test(s) that do not run on this machine, deferring to CI, which covers all platforms: test/cli/install/bun-install.test.ts

A key of a packument's `versions` object that does not parse as a
version was logged as an error. The install resolved, downloaded and
saved the lockfile, then exited with code 1, because any error in a
task log marks the install as failed. bunx and bun create stopped
before they ran the binary. With a warm manifest cache the same install
exited with code 0.

Skip the key like npm does. Keep the diagnostic as a warning under
--verbose, with a message that names the version key and the package
and escapes control characters in both.
@robobun

robobun commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator Author

Status: fix pushed in #43115 (stacked on #43035), waiting for CI.

Reproduction (loopback registry only). A local Bun.serve registry answers each manifest request with the packument below and serves a tarball for each .tgz URL. A bunfig.toml in the project sets [install] registry to that server and cache = false. The project depends on "evil": "1.0.0". Then run bun install.

{ "name": "evil", "dist-tags": { "latest": "1.0.0" }, "versions": { "1.0.0": { "name": "evil", "version": "1.0.0", "dist": { "tarball": "<registry>/evil-1.0.0.tgz" } }, "1.0.0.1": { "name": "evil", "version": "1.0.0.1", "dist": { "tarball": "<registry>/evil-1.0.0.tgz" } } } }

Results:

  • Release build (1.4.3-canary c6b7fcb): prints error: Failed to parse dependency 1.0.0.1, installs evil@1.0.0, saves the lockfile, exit 1. bun add evil and bun update do the same. bunx evil and bun create evil exit 1 and do not run the binary.
  • Debug build of install: stop asserting on registry manifest contents in debug builds #43035: the same results as the release build.
  • Debug build of this branch: no message, exit 0, and bunx evil runs the binary. With --verbose: warn: Skipping version "1.0.0.1" of "evil": not a valid semver version.
  • npm 11.16.0 on the same registry: no message, exit 0.

The tests are in test/cli/install/bun-install.test.ts. Run them with bun bd test test/cli/install/bun-install.test.ts -t "versions keys that are not versions". On the release build and on a debug build of #43035, 3 of 3 fail with exit code 1. On this branch 3 of 3 pass.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code review found no issues

No high-confidence issues detected in this change.

One verified lower-impact observation (a convention, logging or cleanup point) was not posted.

@Jarred-Sumner
Jarred-Sumner merged commit a39b8b0 into robobun/ffab3bc7/install-no-assert-on-registry-data Sep 17, 2026
10 checks passed
@Jarred-Sumner
Jarred-Sumner deleted the robobun/ac64d21b/install-skip-invalid-manifest-version-key branch September 17, 2026 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants