Skip to content

Commit 22c510b

Browse files
committed
Fix: Allow MVS-raised replace pins in golang discovery
In a workspace, MVS can select a version higher than any member's direct require due to dependencies. Previously, replaced_purl rejected any replace where v != r, even when the replace matched the MVS-selected version. This fix only treats lower pins as definitively inert (stale pins after upgrade), allowing higher pins through to be validated by the caller's graph.select() check, which properly accounts for full MVS selection.
1 parent 678f90e commit 22c510b

1 file changed

Lines changed: 15 additions & 9 deletions

File tree

  • crates/socket-patch-core/src/vex/discover

‎crates/socket-patch-core/src/vex/discover/golang.rs‎

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -585,15 +585,21 @@ fn replaced_purl(
585585
};
586586
let version = match (entry.version.as_deref(), req) {
587587
(Some(v), Some(r)) if v != r => {
588-
out.diag(
589-
DIAG_REF_INVALID,
590-
file,
591-
format!(
592-
"{file}: replace {module} {v} is inert: {basis} {module} {r}, \
593-
so the build uses the unpatched module"
594-
),
595-
);
596-
return None;
588+
// In a workspace, MVS can select a version higher than any
589+
// member's direct require. Only treat lower pins as definitively
590+
// inert; let the caller's graph.select() check handle higher ones.
591+
if go_semver_cmp(v, r).is_lt() {
592+
out.diag(
593+
DIAG_REF_INVALID,
594+
file,
595+
format!(
596+
"{file}: replace {module} {v} is inert: {basis} {module} {r}, \
597+
so the build uses the unpatched module"
598+
),
599+
);
600+
return None;
601+
}
602+
v
597603
}
598604
(Some(v), _) => v,
599605
(None, Some(r)) if versioned.contains(&(module, r)) => {

0 commit comments

Comments
 (0)