Skip to content

Handle registry-qualified versions and runtimes in pnpm lockfiles - #1913

Open
Michael McKenzie (mmckenziedev) wants to merge 3 commits into
microsoft:mainfrom
mmckenziedev:mmckenzie/pnpm-registry-qualified-versions
Open

Michael McKenzie (mmckenziedev) wants to merge 3 commits into
microsoft:mainfrom
mmckenziedev:mmckenzie/pnpm-registry-qualified-versions

Conversation

@mmckenziedev

Copy link
Copy Markdown

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.

  • Normalize registry-qualified component versions while retaining the full snapshot keys for dependency-graph lookups.
  • Skip pnpm-managed runtime: entries instead of reporting them as npm packages, and ignore unused resolution metadata so nested variations do not block detection.
  • Add regression tests, increment the Pnpm detector version from 9 to 10, and document the remaining pnpm v10-v12 compatibility work.

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:

  • Focused pnpm tests: 58 passed.
  • Detector test project and CLI builds: passed with no warnings or errors.
  • Real schema 9 and synthetic runtime lockfile scans: passed; npm packages remained detectable and managed runtimes were skipped.

The full test suite and CI snapshot verification were not run for this draft.

New Detector Checklist

Not applicable: this updates an existing detector.

  • I have gone through the docs for creating a new detector here
  • My new detector implements IDefaultOffComponentDetector
  • I have created a PR to the verification repo with components that my new detector can find
  • (If necessary) I have updated the Feature Overview table in the README

Michael McKenzie and others added 2 commits November 18, 2026 11:17
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
Copilot AI balanced review requested due to automatic review settings November 18, 2026 21:06
@mmckenziedev Michael McKenzie (mmckenziedev) changed the title Mmckenzie/pnpm registry qualified versions Handle registry-qualified versions and runtimes in pnpm lockfiles Nov 18, 2026
@mmckenziedev
Michael McKenzie (mmckenziedev) marked this pull request as ready for review November 18, 2026 21:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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

@mmckenziedev

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree company="Microsoft"

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

A remaining documentation nit asks for clarification that managed-runtime entries remain in components without registration and that indirect traversal must also skip runtime edges.

1 open issue

Review effort: Max

Updated comments to clarify handling of local packages and runtimes.

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Copilot AI max review requested due to automatic review settings November 18, 2026 21:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Human assessment is needed to weigh the optional concerns about test isolation and exclusion-helper naming clarity.

No open issues 🎉

1 resolved since last review

Review effort: Max

@@ -0,0 +1,88 @@
# pnpm v10-v12 detector support tracker

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we ignoring this, even with a breaking change it should only leave it empty, no need to ignore preexisting contracts afaik

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.

3 participants