fix: direct parent version collision when same package installed at multiple versions - #1051
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When the same package name is installed at multiple different versions in the dependency tree (e.g.
eslint@9.36.0at root andeslint@6.14.0nested), the name-keyedMapinresolveDirectParentContextwas last-write-wins, producing a wrongcurrentVersionbaseline for the direct parent. This caused CVE Lite CLI to suggest version numbers from the wrong instance - including downgrades.Fixed by using
findPackageAlongPathto match the specific installed instance along the actual dependency path, falling back to the Map lookup when no path match exists.Closes #1050