Repository navigation
Description
When a pnpm-lock.yaml (lockfileVersion: '9.0') contains a scoped git dependency whose resolved package key includes @ in the URL (such as git@... over SSH or <user>@... over HTTPS), parsePnpmProject throws PnpmOutOfSyncError when strictOutOfSync is true and drops all of that package's transitive dependencies when strictOutOfSync is false.
Reproduction:
mkdir -p repro-runner/proj && cd repro-runner
npm init -y >/dev/null
npm install snyk-nodejs-lockfile-parser@2.10.9
cat > proj/package.json <<'EOF'
{
"name": "repro-app",
"version": "1.0.0",
"dependencies": {
"@vercel/fun": "git+https://x-access-token:@github.com/zeit/fun.git#9e3f24bb5643436acecfe8a39bd9c4be37d31ea4"
}
}
EOF
(cd proj && npx --yes pnpm@10.10.0 install --lockfile-only)
node -e '
const fs = require("fs");
const { parsePnpmProject } = require("snyk-nodejs-lockfile-parser");
const pkgJson = fs.readFileSync("proj/package.json", "utf8");
const lockYaml = fs.readFileSync("proj/pnpm-lock.yaml", "utf8");
(async () => {
try {
await parsePnpmProject(pkgJson, lockYaml, {
includeDevDeps: false,
includeOptionalDeps: false,
strictOutOfSync: true,
pruneWithinTopLevelDeps: false,
});
} catch (err) {
console.log("strictOutOfSync: true ->", err.name + ":", err.detail);
}
const dg = await parsePnpmProject(pkgJson, lockYaml, {
includeDevDeps: false,
includeOptionalDeps: false,
strictOutOfSync: false,
pruneWithinTopLevelDeps: false,
});
console.log("strictOutOfSync: false ->", dg.getPkgs().length, "packages:", JSON.stringify(dg.getPkgs()));
})();
'proj/pnpm-lock.yaml (lockfileVersion: '9.0') resolves 49 dependencies and records @vercel/fun under packages without a separate name field (the same @scope/pkg@git+... key shape pnpm v9/v10 writes for SSH git URLs like git@github.com:... and non-GitHub git hosts):
'@vercel/fun@git+https://x-access-token@github.com/zeit/fun.git#9e3f24bb5643436acecfe8a39bd9c4be37d31ea4':
resolution: {commit: 9e3f24bb5643436acecfe8a39bd9c4be37d31ea4, repo: https://x-access-token@github.com/zeit/fun.git, type: git}
version: 0.0.0-developmentActual output:
strictOutOfSync: true -> PnpmOutOfSyncError: Dependency @vercel/fun@0.0.0-development was not found in pnpm-lock.yaml. Your package.json and pnpm-lock.yaml are probably out of sync. Please run "pnpm install" and try again.
strictOutOfSync: false -> 2 packages: [{"name":"repro-app","version":"1.0.0"},{"name":"@vercel/fun","version":"0.0.0-development"}]
Expected output: parsePnpmProject succeeds with strictOutOfSync: true and returns a DepGraph containing all 50 packages (repro-app@1.0.0, @vercel/fun@0.0.0-development, and its 48 transitive dependencies).
Tested on snyk-nodejs-lockfile-parser@2.10.9 and main (f2254ed09c70), with pnpm 10.10.0 and 9.15.9 (lockfileVersion: '9.0'), Node v22.21.1 on Linux x86_64.
In lib/dep-graph-builders/pnpm/lockfile-parser/lockfile-v6.ts, LockfileV6Parser.parseDepPath (inherited by LockfileV9Parser, where packages entries omit name) splits scoped depPath keys with depPath.lastIndexOf('@'), which splits on the @ inside the git URL instead of the @ after @scope/name and produces name: '@vercel/fun@git+https://x-access-token'.
Credit: https://ucsbplse.github.io/
Activity