fix(bun): accept bun.lock lockfileVersion 2 — bun 1.4 re-versioned an unchanged grammar - #224
Open
Mikola Lysenko (mikolalysenko) wants to merge 1 commit into
Open
fix(bun): accept bun.lock lockfileVersion 2 — bun 1.4 re-versioned an unchanged grammar#224Mikola Lysenko (mikolalysenko) wants to merge 1 commit into
Mikola Lysenko (mikolalysenko) wants to merge 1 commit into
Conversation
… unchanged grammar
bun 1.4.0 bumped the default bun.lock lockfileVersion to 2 (oven-sh/bun
PR #31539). The bump gates stricter PARSE checks — integrity hashes
required for off-registry npm tarballs, unsafe git .bun-tag values
rejected — behind an UNCHANGED emitted grammar: a 1.3.14 and a 1.4.0
lock of the same fixture are byte-identical except the integer
(verified empirically in docker). Our hosted/vendored tuples always
carry a sha512, satisfying the new off-registry-integrity rule by
construction.
CI's hosted-e2e job installs floating bun@1, which now resolves to
1.4.0 — the shared version gate (check_lock_version in bun_lock_text)
refused everything but 1, so bun_hosted_install_proof went red on every
push to main. Widen the gate to {1, 2}; refuse anything else with the
updated fail-closed message. The floating bun@1 is deliberately kept:
catching exactly this drift is the hosted suite's job.
Covered call sites: redirect rewriter (redirect_bun_lock_unsupported),
vendor backend (vendor_lockfile_version_unsupported), lock inventory,
plus a v1-only fixture assertion in the vendor bun e2e capstone.
New golden fixture npm/bun/lock-v2 (Rust-authored — the depscan TS twin
needs the matching acceptance + fixture sync); the existing
lock-version-unsupported input re-pinned from 2 to 3 (2 is now
supported). No existing expected/ bytes re-blessed.
Proofs, all with real bun 1.4.0 on PATH: redirect + vendor e2e
capstones green on NATIVE v2 locks (fresh-checkout frozen installs of
patched bytes, tamper refusal), and the exact red CI leg
bun_hosted_install_proof green against real production.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Why main is red
The required
hosted-e2echeck fails on every push (main run 32378974818 and the post-#222 run; every open PR too). The job installs floatingnpm install -g bun@1, which since bun 1.4.0's release (~2026-08-20) resolves to 1.4.0 — and bun 1.4.0 writesbun.lockwith"lockfileVersion": 2. Both of our bun lock version gates refused anything but 1, so thebun_hosted_install_proofleg fails at the rewrite step (redirect_bun_lock_unsupported: "bun.lock lockfileVersion is not 1; re-lock with bun >= 1.3"). 15/16 other legs stayed green; the bun crawler was never affected — only the version gates refuse.What lockfileVersion 2 actually is
Empirically (docker
oven/bun:1.3.14vsoven/bun:1.4.0, same minimist fixture): the two locks are byte-identical except the version integer —"configVersion": 1is present in both, so it is not new in 1.4.Bun's 1.4 breaking-changes tracker (oven-sh/bun#28792, PR #31539) confirms the bump gates stricter parse-time checks over an unchanged emitted grammar:
Both new constraints are compat-neutral for us: our hosted/vendored URL 3-tuples always carry a sha512 (satisfying the off-registry-integrity rule by construction), and we never emit or edit git entries.
The fix
One shared gate, widened from
{1}to{1, 2}(fail-closed on everything else, message updated to "not 1 or 2"):crates/socket-patch-core/src/vendor/bun_lock_text.rs—SUPPORTED_LOCK_VERSIONS/check_lock_version, the single production gate, with three call sites:crates/socket-patch-core/src/patch/redirect/mod.rs(rewrite_bun_lock→redirect_bun_lock_unsupported)crates/socket-patch-core/src/vendor/bun_lock.rs(vendor backend →vendor_lockfile_version_unsupported)crates/socket-patch-core/src/vendor/lock_inventory.rs(inventory_bun— auto-benefits; now test-covered)e2e_vendor_bun_build.rs's fixture precondition assertedlockfileVersion: 1and failed under real bun 1.4.0 — now accepts 1 or 2.CLI_CONTRACT.md+docs/ecosystems.mdbun paragraphs.Tests (RED-first, verified by reverting the gate to v1-only)
With the production gate temporarily re-pinned to
[1], all the new legs fail (v2 refused): thebun_lock_textgate unit,bun_lock::lock_v2_vendors_like_v1, the lock-inventory v2 leg,redirect::tests::bun_lock_warning_branches, andredirect_goldenon the new fixture. With the widened gate, everything is green:in_process_redirectaddsscan_redirect_rewrites_bun_lock_v2(version line preserved verbatim) andscan_redirect_refuses_bun_lock_v3(fail-closed: lock byte-identical,redirected: 0, warning in the--jsonenvelope).lock_v2_vendors_like_v1+ the existing refusal test re-pinned to version 3; inventory reads v1/v2 identically and yields nothing on v3.npm/bun/lock-v2case; the existinglock-version-unsupportedinput re-pinned 2 → 3 (2 is now a supported version, the refusal case needs a future one). No existingexpected/bytes were re-blessed. Loud note: these fixtures are the shared cross-language contract — the newlock-v2case was authored on the Rust side, so the depscan TS twin (golden.test.ts+ its bun rewriter gate) needs the matching v2 acceptance and a fixture sync, same as the gem.ts port.Proof against the real thing
With real bun 1.4.0 on PATH (locally installed, same version CI's
bun@1resolves):e2e_redirect_bun_build: all legs run un-skipped — the main leg now exercises a native v2 lock end-to-end (realbun install, hosted rewrite, fresh-checkoutbun install --frozen-lockfilematerializes the patched bytes; tampered-tarball twin still refuses). Newlock-v2leg pins the forced-version path and asserts the version line survives the rewrite verbatim.e2e_vendor_bun_build: full vendor → frozen install → revert capstone green on a native v2 lock.cargo test -p socket-patch-cli --test e2e_hosted_production bun_hosted_install_proof -- --ignoredagainst real production — green (3.12s).Gates:
cargo test -p socket-patch-core --lib(2540),redirect_golden,in_process_redirect(43),cargo clippy --workspace --all-features -- -D warningsclean, touched filesfmt --checkclean (the repo has pre-existing fmt drift in untouched files; CI has no fmt gate).Deliberately NOT changed
CI's floating
npm install -g bun@1stays floating: it caught this drift within a day of the release — that is precisely the hosted suite's job.🤖 Generated with Claude Code
Note
Medium Risk
Touches lockfile surgery and integrity-pinning for bun hosted/vendor paths, but only widens an existing fail-closed version gate over an empirically unchanged grammar. Unsupported versions still refuse with the lock left byte-identical.
Overview
Accepts bun 1.4's
"lockfileVersion": 2for hosted redirect, vendor, and lock inventory. Bun 1.4 re-versions the same emitted grammar as v1 (stricter parse checks only); the sharedcheck_lock_versiongate now allows{1, 2}and still fail-closes on anything else, preserving the version line verbatim.This unblocks CI that installs floating
bun@1(now 1.4) and was refusing rewrites withredirect_bun_lock_unsupported. Tests cover v2 rewrite/vendor/inventory, v3 refusal, a newlock-v2golden, and e2e fresh-checkout install of patched bytes. Docs (CLI_CONTRACT.md,ecosystems.md) match.Reviewed by Cursor Bugbot for commit 42a4b55. Configure here.