Skip to content

fix: direct parent version collision when same package installed at multiple versions - #1051

Merged
sonukapoor merged 1 commit into
mainfrom
bugfix/direct-parent-version-collision
Aug 27, 2026
Merged

fix: direct parent version collision when same package installed at multiple versions#1051
sonukapoor merged 1 commit into
mainfrom
bugfix/direct-parent-version-collision

Conversation

@sonukapoor

Copy link
Copy Markdown
Collaborator

When the same package name is installed at multiple different versions in the dependency tree (e.g. eslint@9.36.0 at root and eslint@6.14.0 nested), the name-keyed Map in resolveDirectParentContext was last-write-wins, producing a wrong currentVersion baseline for the direct parent. This caused CVE Lite CLI to suggest version numbers from the wrong instance - including downgrades.

Fixed by using findPackageAlongPath to match the specific installed instance along the actual dependency path, falling back to the Map lookup when no path match exists.

Closes #1050

…led at multiple versions

When the same package (e.g. eslint) is installed at multiple versions in the
dependency tree, the packagesByName Map in resolveDirectParentContext kept only
the last entry (last-write-wins). If the nested version appeared last, it
became directParentVersion, causing the candidate filter to admit versions that
are actually downgrades from the root installation (e.g. eslint@6.15.0 when
eslint@9.36.0 is installed at the root).

Fix: use findPackageAlongPath with the path prefix up to and including the
direct parent position in viaPath, falling back to the existing Map lookup.
Path-based iteration finds the specific installed instance on the finding's
dependency path rather than an arbitrary same-name package.

Regression test added for the eslint@9.36.0 / eslint@6.14.0 collision case.
@sonukapoor
sonukapoor merged commit decd033 into main Aug 27, 2026
6 checks passed
@sonukapoor
sonukapoor deleted the bugfix/direct-parent-version-collision branch August 27, 2026 21:31
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.

fix: direct parent version collision when same package installed at multiple versions

1 participant