Ignore link and file versions in Pnpm 6 package dependencies - #1869
Open
RKS (rksharma-owg) wants to merge 2 commits into
Open
RKS (rksharma-owg) wants to merge 2 commits into
RKS (rksharma-owg) wants to merge 2 commits into
Conversation
In the PNPM v6 lockfile format, package dependencies may reference local or workspace packages using link: or file: version paths. Previously, Pnpm6Detector only ignored file: packages in top-level package keys and did not check for local dependencies (file: or link:) when traversing package.Dependencies. This led to KeyNotFoundException lookups in the components map and failed dependency graph construction. This change: 1. Skips both file: and link: dependency paths when discovering packages in yaml.Packages. 2. Skips local package dependencies (file: and link:) when building dependency edges. 3. Bumps PnpmComponentDetectorFactory.Version from 8 to 9.
RKS (rksharma-owg)
requested review from
Joe Schmitt (schmittjoseph)
and
a lite review from Copilot
September 17, 2026 03:41
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
Regression coverage should include local package entries under packages.
Pull request overview
Updates PNPM v6 detection to ignore local link: and file: dependencies while preserving graph construction.
Changes:
- Filters local package paths and dependency references.
- Bumps the detector version from 8 to 9.
- Adds regression coverage for local dependencies.
File summaries
| File | Description |
|---|---|
test/Microsoft.ComponentDetection.Detectors.Tests/PnpmDetectorTests.cs |
Tests PNPM v6 local dependency handling. |
src/Microsoft.ComponentDetection.Detectors/pnpm/PnpmComponentDetectorFactory.cs |
Increments detector version. |
src/Microsoft.ComponentDetection.Detectors/pnpm/Pnpm6Detector.cs |
Filters local package paths and dependency edges. |
Review details
Suppressed comments (2)
src/Microsoft.ComponentDetection.Detectors/pnpm/Pnpm6Detector.cs:29
- The new test exercises
file:/link:values in a package's dependency map, but it never puts afile:orlink:entry underpackages. Consequently, removing this newly added package-key guard would still leave the test green, so the first part of the fix is not regression-tested; add local package entries and assert they are excluded from the detected components.
if (pnpmDependencyPath.StartsWith(PnpmConstants.PnpmFileDependencyPath) || pnpmDependencyPath.StartsWith(PnpmConstants.PnpmLinkDependencyPath))
test/Microsoft.ComponentDetection.Detectors.Tests/PnpmDetectorTests.cs:601
- This fixture covers the new
IsLocalDependencyguard forpackage.Dependenciesvalues, but it never includes alink:key underpackages. The new first-pass condition inPnpm6Detectoris therefore untested and could regress while this test still passes; add a representative local package entry and keep asserting that it is not detected.
packages:
/[email protected]:
resolution: {integrity: sha512-mock=}
dependencies:
pkg-link: link:../pkg-link
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Summary
Ignores
link:andfile:dependencies when traversing package dependencies in PNPM v6 lockfiles.Fixes #1555
Problem
In PNPM v6 lockfiles, packages may reference workspace packages or local packages via
link:(e.g.,link:../pkg) orfile:version specifiers.In
Pnpm6Detector.cs:yaml.Packagesskippedfile:prefixes, it did not skiplink:prefixes in package paths.package.Dependenciesis traversed to register graph edges, local dependencies (file:andlink:) were not skipped.ReconstructPnpmDependencyPathconstructed paths for these local dependencies, but because local packages are not recorded incomponents,components[pnpmDependencyPath]threwKeyNotFoundException.PnpmComponentDetectorFactory.OnFileFoundAsync, terminating dependency edge creation and leaving graph construction incomplete.Solution
Pnpm6Detector.cs, skip package keys starting withPnpmConstants.PnpmLinkDependencyPathin addition toPnpmConstants.PnpmFileDependencyPath.Pnpm6Detector.cs, checkthis.pnpmParsingUtilities.IsLocalDependency(new KeyValuePair<string, string>(name, version))before attempting to reconstruct and look up dependencies incomponents.PnpmComponentDetectorFactory.Versionfrom 8 to 9.Tests
TestPnpmDetector_V6_IgnoresLinkAndFilePackageDependenciesAsynctoPnpmDetectorTests:link:andfile:entries underpackage.Dependenciesparse without throwingKeyNotFoundException.PnpmDetectorTestspass.