Skip to content

Commit 852472c

Browse files
committed
Keep Berry takeover preflight compatible with lock-aware rewrites
1 parent 29bbac4 commit 852472c

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

  • crates/socket-patch-core/src/patch/redirect

‎crates/socket-patch-core/src/patch/redirect/mod.rs‎

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3233,16 +3233,18 @@ fn berry_cache_key(content: &str) -> Option<String> {
32333233
/// compares the file with its own majority-normalized re-render and fails
32343234
/// (YN0028), while a plain install rewrites every minority line — so it is
32353235
/// refused untouched, `yarn install` normalizes it first.
3236-
/// The per-dep refusal of the yarn berry hosted rewriter that depends only
3237-
/// on the grant, not on the lock: a dep whose grant carries no
3238-
/// `yarnBerry10c0` cache checksum cannot be redirected (berry verifies the
3239-
/// converted cache zip, and only the service can compute that checksum).
3236+
/// The grant prerequisite for creating a new yarn berry hosted pin: a dep
3237+
/// whose grant carries no `yarnBerry10c0` cache checksum cannot be redirected
3238+
/// (berry verifies the converted cache zip, and only the service can compute
3239+
/// that checksum).
32403240
///
32413241
/// Exposed for the vendored→hosted mode takeover, like
32423242
/// [`preflight_yarn_berry_hosted`]: vendored mode only uses the `tarball`
32433243
/// artifact, so a vendorable patch can lack the berry checksum, and the
32443244
/// takeover must keep such a package vendored instead of reverting it and
32453245
/// then skipping the redirect.
3246+
/// Keep this unconditional gate at the takeover boundary: a lock-aware
3247+
/// rewriter may retain an already complete pin's stored checksum.
32463248
pub fn preflight_yarn_berry_hosted_dep(dep: &DepOverride) -> Result<(), RewriteWarning> {
32473249
if dep.integrity.yarn_berry10c0.is_some() {
32483250
return Ok(());
@@ -3349,16 +3351,19 @@ fn rewrite_yarn_berry(
33493351
let fname = full_name(dep);
33503352
// The API hands the prefixed `10c0/<hex>`; a yarn 4.0.x lock spells
33513353
// its checksums bare, and `--immutable` rejects a respelled one.
3352-
if let Err(warning) = preflight_yarn_berry_hosted_dep(dep) {
3353-
result.warnings.push(warning);
3354-
continue;
3355-
}
33563354
let Some(checksum) = dep
33573355
.integrity
33583356
.yarn_berry10c0
33593357
.as_deref()
33603358
.map(|c| crate::vendor::yarn_berry_lock::checksum_in_lock_spelling(content, c))
33613359
else {
3360+
result.warnings.push(RewriteWarning {
3361+
code: "redirect_yarn_berry_missing_checksum".into(),
3362+
detail: format!(
3363+
"{fname}@{} has no yarnBerry10c0 cache checksum",
3364+
dep.version
3365+
),
3366+
});
33623367
continue;
33633368
};
33643369
// Berry versions are UNQUOTED (` version: 1.3.0`).

0 commit comments

Comments
 (0)