Repository navigation
Handle registry-qualified versions and runtimes in pnpm lockfiles - #1913
Michael McKenzie (mmckenziedev) wants to merge 3 commits into
Conversation
Lockfiles from pnpm 11.20 and later can key packages from a named registry as `name@<registry>:<version>`. The schema 9 parser reported `<registry>:<version>` as the npm version, which is not a valid version. Report the semantic version while keeping the full key for dependency graph lookups, and bump the Pnpm detector version. Also add a tracker for pnpm v10-v12 lockfile support. Co-authored-by: Copilot <[email protected]> Copilot-Session: deec0df3-ca37-44f4-a7e7-0b1947e8a336
pnpm 10.14 and later record the Node.js, Deno, and Bun runtimes it downloads, and pnpm 12 records Yarn 6, as `<name>@runtime:<version>` entries with nested `variations` resolutions. The schema 9 parser failed on that nested metadata and reported no components for the lockfile. pnpm 12.18 can also write nested resolutions for npm packages from pnpr registries. Stop reading resolution metadata, which the detector never uses, and skip `runtime:` entries instead of reporting them as npm packages with an invalid `runtime:` version. Co-authored-by: Copilot <[email protected]> Copilot-Session: deec0df3-ca37-44f4-a7e7-0b1947e8a336
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the targeted pnpm schema 9 registry-version and managed-runtime compatibility fixes.
No open issues 🎉
What changed in this PR
This PR improves the existing pnpm schema 9 detector’s handling of registry-qualified versions and managed runtimes. It addresses specific compatibility gaps without claiming complete pnpm v10–v12 support; schema 13 remains unsupported.
Changes:
- Normalize registry-qualified npm versions while preserving full snapshot keys for dependency-graph lookups.
- Skip pnpm-managed runtimes and ignore unused resolution metadata so nested variants do not block parsing.
- Add regression tests, increment the detector version to 10, and document remaining compatibility work.
| File | Description |
|---|---|
| test/Microsoft.ComponentDetection.Detectors.Tests/PnpmParsingUtilitiesTest.cs | Tests registry-prefix normalization and preserved protocol prefixes. |
| test/Microsoft.ComponentDetection.Detectors.Tests/PnpmDetectorTests.cs | Tests graph preservation, runtime exclusion, and nested resolution parsing. |
| src/Microsoft.ComponentDetection.Detectors/pnpm/PnpmComponentDetectorFactory.cs | Increments the detector version from 9 to 10. |
| src/Microsoft.ComponentDetection.Detectors/pnpm/Pnpm9Detector.cs | Excludes managed runtimes from detected packages and graph references. |
| src/Microsoft.ComponentDetection.Detectors/pnpm/ParsingUtilities/PnpmV9ParsingUtilities.cs | Normalizes exported registry-qualified versions without changing lookup keys. |
| src/Microsoft.ComponentDetection.Detectors/pnpm/IPnpmDetector.cs | Defines the managed-runtime prefix constant. |
| src/Microsoft.ComponentDetection.Detectors/pnpm/Contracts/Package.cs | Excludes unused resolution metadata from YAML deserialization. |
| docs/detectors/pnpm.md | Documents runtime exclusions and links the compatibility tracker. |
| docs/detectors/pnpm-version-support.md | Tracks implemented fixes and remaining pnpm v10–v12 compatibility work. |
Review effort: Balanced
|
@microsoft-github-policy-service agree company="Microsoft" |
Updated comments to clarify handling of local packages and runtimes. Co-authored-by: Copilot Autofix powered by AI <[email protected]>
| @@ -0,0 +1,88 @@ | |||
| # pnpm v10-v12 detector support tracker | |||
There was a problem hiding this comment.
Let's please remove this markdown file, let's keep our docs human-readable, the pnpm.md should be all we need
| var prefix = packageVersion[..separator]; | ||
|
|
||
| // These pnpm protocol prefixes cannot be named registry aliases. | ||
| if (prefix is "bitbucket" or "catalog" or "custom" or "file" or "git" or "github" or "gitlab" |
There was a problem hiding this comment.
where is this list coming from? This looks a bit brittle and random, but possibly PNPM has a link somewhere about why these protocol prefixes are important. Important to include a link to that doc and a few words for context.
If PNPM defines a registry-name grammar that we can implement/reference that would be great to encapsulate and include a link to docs of where that came from. Something like:
private static bool IsValidRegistryName(string value)
{
return value.Length > 0
&& char.IsAsciiLetter(value[0])
&& value.All(c => char.IsAsciiLetterOrDigit(c) || c is '.' or '_' or '-');
}
| public string Name { get; set; } | ||
|
|
||
| [YamlMember(Alias = "resolution")] | ||
| [YamlIgnore] |
There was a problem hiding this comment.
why are we ignoring this, even with a breaking change it should only leave it empty, no need to ignore preexisting contracts afaik

Description
Schema 9 pnpm lockfiles can contain registry-qualified versions and managed runtimes. These entries could produce invalid npm component versions or prevent a lockfile from being parsed.
runtime:entries instead of reporting them as npm packages, and ignore unused resolution metadata so nested variations do not block detection.pnpm v10-v12 can produce schema 9 lockfiles. These fixes address specific compatibility gaps; they do not establish complete support for every feature. The opt-in schema 13 remains unsupported.
Validation
Previously recorded results; not rerun for this draft:
The full test suite and CI snapshot verification were not run for this draft.
New Detector Checklist
Not applicable: this updates an existing detector.
IDefaultOffComponentDetector