Skip to content

fix(arborist): apply overrides across a file: link (backport release/v11)#9673

Merged
owlstronaut merged 1 commit into
npm:release/v11from
manzoorwanijk:backport/override-across-file-link-v11
Jun 26, 2026
Merged

fix(arborist): apply overrides across a file: link (backport release/v11)#9673
owlstronaut merged 1 commit into
npm:release/v11from
manzoorwanijk:backport/override-across-file-link-v11

Conversation

@manzoorwanijk

Copy link
Copy Markdown
Contributor

Backport of #9671 to release/v11.

A root overrides entry targeting a transitive dependency was silently dropped when the path to that dependency crossed a file:/workspace link, so the dependency resolved to its un-overridden version and the lockfile pinned the wrong version. It reproduced under both the hoisted and linked install strategies, while the same override applied correctly when the dependency was reached without crossing a link.

buildIdealTree now forwards a link's overrides to its target before the target's subtree is resolved, so descendant edges inherit the rule as they are added, matching how a registry node always inherits its ancestor's OverrideSet. loadActual now repropagates overrides through links once all edges are resolved, so a transitive override reached through a file: link is reported as overridden rather than invalid by npm ls.

Backport notes: clean cherry-pick except for the #repropagateOverrides comment, which conflicted only because release/v11 does not have the adjacent #applyPackageExtensions method; resolved by keeping the v11 structure and applying the comment update.

References

Fixes #9659
Backport of #9671

…npm#9671) (backport release/v11)

A root `overrides` entry targeting a transitive dependency was silently
dropped when the path to that dependency crossed a `file:`/workspace
link, so the dependency resolved to its un-overridden version and the
lockfile pinned the wrong version. It reproduced under both the
`hoisted` and `linked` install strategies, while the same override
applied correctly when the dependency was reached without crossing a
link.

Override rules propagate through dependency edges, but a Link and its
target are not edge-connected, so they are bridged by forwarding the
Link's `OverrideSet` to its target. That forwarding ran while the
target's subtree was still unbuilt, so its guard found no matching rule
and never forwarded, leaving the target and its descendant edges without
the rule.

`buildIdealTree` now forwards a link's overrides to its target before
the target's subtree is resolved, so descendant edges inherit the rule
as they are added, matching how a registry node always inherits its
ancestor's `OverrideSet`. `loadActual` now repropagates overrides
through links once all edges are resolved, so a transitive override
reached through a `file:` link is reported as `overridden` rather than
`invalid` by `npm ls`.

Fixes npm#9659

(cherry picked from commit 968e42f)
@manzoorwanijk manzoorwanijk marked this pull request as ready for review June 26, 2026 13:41
@manzoorwanijk manzoorwanijk requested review from a team as code owners June 26, 2026 13:41
@manzoorwanijk manzoorwanijk changed the title fix(arborist): apply overrides across a file:/workspace link boundary (backport release/v11) fix(arborist): apply overrides across a file: link (backport release/v11) Jun 26, 2026
@owlstronaut owlstronaut merged commit 719de1e into npm:release/v11 Jun 26, 2026
16 of 17 checks passed
@manzoorwanijk manzoorwanijk deleted the backport/override-across-file-link-v11 branch June 26, 2026 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants