Repository navigation
install: skip a registry manifest versions key that is not a version - #43115
Merged
Jarred-Sumner merged 2 commits intoSep 17, 2026
Conversation
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.
Collaborator
Author
|
Status: fix pushed in #43115 (stacked on #43035), waiting for CI. Reproduction (loopback registry only). A local { "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:
The tests are in |
Jarred-Sumner
merged commit Sep 17, 2026
a39b8b0
into
robobun/ffab3bc7/install-no-assert-on-registry-data
10 checks passed
Jarred-Sumner
deleted the
robobun/ac64d21b/install-skip-invalid-manifest-version-key
branch
September 17, 2026 21:37
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #43117. Stacked on #43035. Review the last commit.
Problem
versionskey that is not a version (such as1.0.0.1) breaks each fresh resolve of that package.bun install,bun addandbun updateprinterror: Failed to parse dependency 1.0.0.1, complete the install, and exit 1.bunxandbun createrunbun addfirst, 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
--verbose, bun logswarn: Skipping version "1.0.0.1" of "bar": not a valid semver version. It is verbose-only, like the registry name mismatch in this function (npm.rs:2078): the user cannot change registry data.test/cli/install/bun-install.test.tsfail with exit 1 on release 1.4.3-canary and on a debug build of install: stop asserting on registry manifest contents in debug builds #43035. They replace the install: stop asserting on registry manifest contents in debug builds #43035 test that pins exit code 1. Ten more install suites pass (Notes).Background
versionsmaps each version string to that version's fields.run_tasksprints that log on the main thread.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 twodebug_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: thebunx,bun create, lockfile andbun publishfacts below were added, each from a run.Commands. One packument with the keys
not-a-versionand1.0.0, a localBun.serveregistry, no manifest cache. Each row was run on release 1.4.3-canary (c6b7fcb) and on a debug build of this branch.bun installbun add evilbun updatebunx evil,bunx evil@latest,bunx evil@1.0.0bun create evilbun outdatedbun pm view evilnpm install(11.16.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_modulesand 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 publishsends theversionfield with no check. A local Verdaccio 6.0.0 acceptsbun publishof1.0.0and of1.0.0.1for one package. Both publishes exit 0, and the packument lists both keys.bun installof1.0.0from a clean project then exits 1 witherror: Failed to parse dependency 1.0.0.1on release, and 0 on this branch.npm publishrefuses the same package:npm error Invalid version: "1.0.0.1".Keys that
Version::parserejects (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 as1,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 aboveu64::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.1in the packument,"evil": "1.0.0.1"exits 1 witherror: No version matching "1.0.0.1" found for specifier "evil" (but package exists)."evil": "not-a-version"exits 1 witherror: 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 mismatchwarning 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
--verboseit keeps the position in the packument: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
ESCandBELbytes. The new message goes throughbun_fmt::quote. For the keyESC [31mred BELit prints"\^[[31mred\^G".Not in this PR.
bun publishaccepts aversionthat 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, andbun 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 fetchhttps://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