Skip to content

Commit d475268

Browse files
committed
Guard Bun manifests for explicit patch retrieval
Apply Bun compatibility preflight to get by UUID as well as search. Exercise both entry points across the native release matrix. Assisted-by: Codex:gpt-6-astra
1 parent cfc1e96 commit d475268

3 files changed

Lines changed: 34 additions & 3 deletions

File tree

‎crates/socket-patch-cli/src/commands/get.rs‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2950,6 +2950,31 @@ async fn run_get_vendored_uuid(
29502950
return 0;
29512951
}
29522952

2953+
if patch.purl.starts_with("pkg:npm/") {
2954+
if let Err((code, message)) =
2955+
socket_patch_core::vendor::bun_lock::preflight_vendor(&args.common.cwd).await
2956+
{
2957+
if args.common.json {
2958+
print_json(&serde_json::json!({
2959+
"status": "error",
2960+
"found": 1,
2961+
"downloaded": 0,
2962+
"failed": 1,
2963+
"error": { "code": code, "message": message },
2964+
"patches": [{
2965+
"purl": patch.purl,
2966+
"uuid": patch.uuid,
2967+
"action": "failed",
2968+
"errorCode": code,
2969+
}],
2970+
}));
2971+
} else if !args.common.silent {
2972+
eprintln!("Error ({code}): {message}");
2973+
}
2974+
return 1;
2975+
}
2976+
}
2977+
29532978
note_vendored_whole_manifest_scope(&manifest_path, &[patch.purl.as_str()], quiet).await;
29542979

29552980
let action = match save_patch_record(args, patch, false, false).await {

‎docs/testing/bun-compatibility.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ Every supported case verifies:
2525

2626
The runner captures the exact project manifests, lockfiles, optional `.socket/manifest.json`, CLI JSON, file hashes and assertion results. Socket SBOM tests import these captures through their existing fixture validation framework. Vendored artifact contents are verified by the native runner; they are not needed for SBOM lockfile annotation.
2727

28+
The `get-uuid` and `get-search` cases also exercise explicit patch retrieval by UUID and PURL, including refusal before manifest writes on unsupported Bun projects.
29+
2830
## Boundaries verified by the matrix
2931

3032
| Configuration | Behavior |

‎scripts/backtest-bun.py‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
'1.2.0', '1.2.23', '1.3.0', '1.3.14', '1.4.0', '1.4.2']
2020
SHAPES = ['direct', 'dev', 'optional', 'alias', 'transitive', 'two-versions',
2121
'workspace', 'workspace-nested', 'peer', 'crlf', 'space-unicode',
22-
'custom-registry', 'text', 'isolated', 'hoisted', 'lockfile-only', 'production']
22+
'custom-registry', 'text', 'isolated', 'hoisted', 'lockfile-only', 'production',
23+
'get-uuid', 'get-search']
2324
PURL = 'pkg:npm/minimist@1.2.2'
2425
UUID = '80630680-4da6-45f9-bba8-b888e0ffd58c'
2526

@@ -183,7 +184,8 @@ def backtest(job):
183184
checks['installedBefore'] = bool(installed_targets(project))
184185
if shape == 'lockfile-only':
185186
shutil.rmtree(project / 'node_modules')
186-
command = [cli, 'scan', '--mode', 'vendored' if mode == 'vendored-detached' else mode, '--cwd', project,
187+
verb = ['get', UUID if shape == 'get-uuid' else PURL] if shape.startswith('get-') else ['scan']
188+
command = [cli, *verb, '--mode', 'vendored' if mode == 'vendored-detached' else mode, '--cwd', project,
187189
'--json', '--yes', '--no-telemetry']
188190
if mode == 'vendored-detached':
189191
command.append('--detached')
@@ -197,6 +199,7 @@ def backtest(job):
197199
row['refusals'] = [w.get('code', w.get('errorCode')) for w in warnings]
198200
row['refusals'] += [p['errorCode'] for p in envelope.get('download', {}).get('patches', [])
199201
if p.get('errorCode')]
202+
row['refusals'] += [p['errorCode'] for p in envelope.get('patches', []) if p.get('errorCode')]
200203
row['applied'] = applied
201204
if not checks['installedBefore'] and version in ['0.8.1', '1.0.0'] and shape in ['peer', 'transitive']:
202205
row['supported'] = False
@@ -301,7 +304,8 @@ def backtest(job):
301304

302305
jobs = [(v, s, m) for v in args.versions for s in args.shapes for m in args.modes
303306
if (s not in ('isolated', 'hoisted') or tuple(map(int, v.split('.'))) >= (1, 3, 0))
304-
and (s != 'text' or tuple(map(int, v.split('.'))) >= (1, 1, 38))]
307+
and (s != 'text' or tuple(map(int, v.split('.'))) >= (1, 1, 38))
308+
and (not s.startswith('get-') or m != 'vendored-detached')]
305309
with concurrent.futures.ThreadPoolExecutor(max_workers=args.jobs) as pool:
306310
rows = list(pool.map(backtest, jobs))
307311
save(root / 'summary.json', rows)

0 commit comments

Comments
 (0)