IDETECT-5225 : Fix pnpm 11 multi-document lockfile parsing selecting wrong dependency section - #1837
Open
bd-spratikbharti wants to merge 13 commits into
Open
IDETECT-5225 : Fix pnpm 11 multi-document lockfile parsing selecting wrong dependency section#1837bd-spratikbharti wants to merge 13 commits into
bd-spratikbharti wants to merge 13 commits into
Conversation
# Conflicts: # detectable/src/main/java/com/blackduck/integration/detectable/detectables/pnpm/lockfile/process/PnpmLockYamlParserInitial.java
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
# Conflicts: # documentation/src/main/markdown/currentreleasenotes.md
… or lower version testing
…y section when both the documents in the lockfile contained the lockfileversion
bd-spratikbharti
requested review from
bd-samratmuk,
dterrybd and
shantyk
and
a lite review from Copilot
August 5, 2026 18:36
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates Detect’s pnpm lockfile parsing to correctly handle pnpm 11’s multi-document pnpm-lock.yaml format by selecting the dependency document deterministically, and adds regression coverage for the case where both YAML documents contain lockfileVersion.
Changes:
- Update pnpm multi-document lockfile document selection to use a position-based rule (choose the last document when multiple are present).
- Add a new functional test and a pnpm 11 multi-document fixture where both documents include
lockfileVersion. - Update the “current release notes” markdown content.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| documentation/src/main/markdown/currentreleasenotes.md | Updates current release notes content (notices + 12.0.0 entries). |
| detectable/src/main/java/com/blackduck/integration/detectable/detectables/pnpm/lockfile/process/PnpmLockYamlParserInitial.java | Selects the correct YAML document in pnpm 11+ multi-document lockfiles by choosing the last parsed lockfile document. |
| detectable/src/test/java/com/blackduck/integration/detectable/detectables/pnpm/functional/PnpmLockYamlParserMultiDocTest.java | Adds regression test ensuring the parser selects the correct document when both documents include lockfileVersion. |
| detectable/src/test/resources/detectables/functional/pnpm/v11-multi-doc-both-versions/pnpm-lock.yaml | Adds a pnpm 11 multi-document lockfile fixture where document 1 is a “trap” and document 2 contains real dependencies. |
Files not reviewed (1)
- detectable/src/test/resources/detectables/functional/pnpm/v11-multi-doc-both-versions/pnpm-lock.yaml: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
21
to
+25
| ## Version 12.0.0 | ||
|
|
||
| ### New features | ||
|
|
||
| * The Bazel detector now classifies Bazel Central Registry (BCR) dependencies as direct or transitive when running in Bzlmod mode on Bazel 7.1 or later. | ||
| * Introduced the property `detect.project.version.create.when.no.components` (default: true). When configured to false, [detect_product_short] will refrain from creating a project version in [bd_product_long] in cases where no components are identified and no other scan tools are active. | ||
| * Support for npm has been extended to 11.13.0 and Node.js 24.17.0. |
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.
Description
Problem
pnpm 11 introduced a new lockfile format with two sections (YAML documents) separated by
---:Both documents can contain a
lockfileVersionfield. The parser was picking the first document it found withlockfileVersion, which meant it extracted config dependencies instead of real project dependencies.Solution
Changed the document selection logic to be position-based instead of content-based:
This ensures we extract the correct dependencies while maintaining backward compatibility with older lockfile formats.
Testing
lockfileVersion