Skip to content

Commit 72b5bf1

Browse files
a-schuryeikel
andauthored
bun: preserve configVersion field in lockfiles (#13694)
* bun: preserve configVersion field in lockfiles Fixes #13623 Upgrades Bun from v1.2.5 to v1.3.3 and updates the lockfile parser to recognize and preserve the configVersion field introduced in Bun v1.3.2. The configVersion field (0 or 1) indicates which install behavior Bun should use: - 0: existing projects using the hoisted linker - 1: new projects with the isolated linker for workspace support Changes: - Upgrade BUN_VERSION from 1.2.5 to 1.3.3 in Dockerfile - Add configVersion validation in BunLock parser - Add test fixtures with configVersion field - Add test coverage for valid and invalid configVersion values * clarified configVersion preservation comments * Update bun/lib/dependabot/bun/file_parser/bun_lock.rb Co-authored-by: Yeikel Santana <[email protected]> --------- Co-authored-by: Yeikel Santana <[email protected]>
1 parent 77efa52 commit 72b5bf1

File tree

6 files changed

+98
-1
lines changed

6 files changed

+98
-1
lines changed

bun/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ FROM ghcr.io/dependabot/dependabot-updater-core
55
ARG COREPACK_VERSION=0.33.0
66

77
# Check for updates at https://github.com/oven-sh/bun/releases
8-
ARG BUN_VERSION=1.2.5
8+
ARG BUN_VERSION=1.3.3
99

1010
# See https://github.com/nodesource/distributions#installation-instructions
1111
ARG NODEJS_VERSION=20

bun/lib/dependabot/bun/file_parser/bun_lock.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ def parsed
3232
raise_invalid!("expected 'lockfileVersion' to be an integer") unless version.is_a?(Integer)
3333
raise_invalid!("expected 'lockfileVersion' to be >= 0") unless version >= 0
3434

35+
# configVersion was introduced in Bun v1.3.2 to control install behavior.
36+
# When present, it must be preserved or Bun will use different install defaults.
37+
# See https://bun.sh/blog/bun-v1.3.2#lockfile-configversion-stabilizes-install-defaults
38+
if content.key?("configVersion")
39+
config_version = content["configVersion"]
40+
unless config_version.is_a?(Integer) && config_version >= 0
41+
raise_invalid!("expected 'configVersion' to be a non-negative integer")
42+
end
43+
end
44+
3545
T.let(content, T.untyped)
3646
end
3747
end

bun/spec/dependabot/bun/file_parser/lockfile_parser_spec.rb

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,29 @@
3737
end
3838
end
3939

40+
context "when the configVersion is invalid" do
41+
let(:dependency_files) do
42+
[
43+
Dependabot::DependencyFile.new(
44+
name: "package.json",
45+
content: '{"dependencies": {"etag": "^1.0.0"}}'
46+
),
47+
Dependabot::DependencyFile.new(
48+
name: "bun.lock",
49+
content: '{"lockfileVersion": 0, "configVersion": "invalid", "workspaces": {}, "packages": {}}'
50+
)
51+
]
52+
end
53+
54+
it "raises a DependencyFileNotParseable error" do
55+
expect { dependencies }
56+
.to raise_error(Dependabot::DependencyFileNotParseable) do |error|
57+
expect(error.file_name).to eq("bun.lock")
58+
expect(error.message).to include("configVersion")
59+
end
60+
end
61+
end
62+
4063
context "when dealing with v0 format" do
4164
context "with a simple project" do
4265
let(:dependency_files) { project_dependency_files("bun/simple_v0") }
@@ -90,6 +113,24 @@
90113
expect(dependencies.length).to eq(17)
91114
end
92115
end
116+
117+
context "when the lockfile has configVersion" do
118+
context "with configVersion: 0" do
119+
let(:dependency_files) { project_dependency_files("bun/simple_v0_with_config_version") }
120+
121+
it "parses dependencies properly" do
122+
expect(dependencies.find { |d| d.name == "fetch-factory" }).to have_attributes(
123+
name: "fetch-factory",
124+
version: "0.0.1"
125+
)
126+
expect(dependencies.find { |d| d.name == "etag" }).to have_attributes(
127+
name: "etag",
128+
version: "1.8.1"
129+
)
130+
expect(dependencies.length).to eq(11)
131+
end
132+
end
133+
end
93134
end
94135
end
95136
end
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"lockfileVersion": 0,
3+
"configVersion": 0,
4+
"workspaces": {
5+
"": {
6+
"dependencies": {
7+
"fetch-factory": "^0.0.1",
8+
},
9+
"devDependencies": {
10+
"etag": "^1.0.0",
11+
},
12+
},
13+
},
14+
"packages": {
15+
"encoding": ["[email protected]", "", { "dependencies": { "iconv-lite": "^0.6.2" } }, "sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A=="],
16+
17+
"es6-promise": ["[email protected]", "", {}, "sha512-SOp9Phqvqn7jtEUxPWdWfWoLmyt2VaJ6MpvP9Comy1MceMXqE6bxvaTu4iaxpYYPzhny28Lc+M87/c2cPK6lDg=="],
18+
19+
"etag": ["[email protected]", "", {}, "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg=="],
20+
21+
"fetch-factory": ["[email protected]", "", { "dependencies": { "es6-promise": "^3.0.2", "isomorphic-fetch": "^2.1.1", "lodash": "^3.10.1" } }, "sha512-gexRwqIhwzDJ2pJvL0UYfiZwW06/bdYWxAmswFFts7C87CF8i6liApihTk7TZFYMDcQjvvDIvyHv0q379z0aWA=="],
22+
23+
"iconv-lite": ["[email protected]", "", { "dependencies": { "safer-buffer": ">= 2.1.2 < 3.0.0" } }, "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw=="],
24+
25+
"is-stream": ["[email protected]", "", {}, "sha512-uQPm8kcs47jx38atAcWTVxyltQYoPT68y9aWYdV6yWXSyW8mzSat0TL6CiWdZeCdF3KrAvpVtnHbTv4RN+rqdQ=="],
26+
27+
"isomorphic-fetch": ["[email protected]", "", { "dependencies": { "node-fetch": "^1.0.1", "whatwg-fetch": ">=0.10.0" } }, "sha512-9c4TNAKYXM5PRyVcwUZrF3W09nQ+sO7+jydgs4ZGW9dhsLG2VOlISJABombdQqQRXCwuYG3sYV/puGf5rp0qmA=="],
28+
29+
"lodash": ["[email protected]", "", {}, "sha512-9mDDwqVIma6OZX79ZlDACZl8sBm0TEnkf99zV3iMA4GzkIT/9hiqP5mY0HoT1iNLCrKc/R1HByV+yJfRWVJryQ=="],
30+
31+
"node-fetch": ["[email protected]", "", { "dependencies": { "encoding": "^0.1.11", "is-stream": "^1.0.1" } }, "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ=="],
32+
33+
"safer-buffer": ["[email protected]", "", {}, "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="],
34+
35+
"whatwg-fetch": ["[email protected]", "", {}, "sha512-EqhiFU6daOA8kpjOWTL0olhVOF3i7OrFzSYiGsEMB8GcXS+RrzauAERX65xMeNWVqxA6HXH2m69Z9LaKKdisfg=="],
36+
}
37+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"dependencies": {
3+
"fetch-factory": "^0.0.1"
4+
},
5+
"devDependencies": {
6+
"etag": "^1.0.0"
7+
}
8+
}

bun/spec/fixtures/projects/bun/simple_v1/bun.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"lockfileVersion": 1,
3+
"configVersion": 1,
34
"workspaces": {
45
"": {
56
"name": "project_new",

0 commit comments

Comments
 (0)