Idetect 5146 - fix(pnpm): allow scan to complete when lockfile has no dependencies#1796
Open
bd-spratikbharti wants to merge 5 commits into
Open
Idetect 5146 - fix(pnpm): allow scan to complete when lockfile has no dependencies#1796bd-spratikbharti wants to merge 5 commits into
bd-spratikbharti wants to merge 5 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Improves pnpm lockfile parsing so scans can complete (producing empty dependency graphs) when pnpm-lock.yaml has no packages section, and updates v5/v6+ detection to validate lockfileVersion rather than relying on exception-based fallback.
Changes:
- Stop failing graph construction when
packagesis missing; instead skip graph building and continue with an empty graph. - Add warnings for lockfiles missing
packages(root + workspace/importers cases). - Update initial parsing to prefer v6/v9 parsing when
lockfileVersionindicates v6+, and add handling for empty lockfiles / nulllockfileVersion.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| detectable/src/main/java/com/blackduck/integration/detectable/detectables/pnpm/lockfile/process/PnpmYamlTransformerv5.java | Skip v5 graph building when packages is absent instead of throwing. |
| detectable/src/main/java/com/blackduck/integration/detectable/detectables/pnpm/lockfile/process/PnpmYamlTransformer.java | Skip v6+/v9 graph building when packages is absent instead of throwing. |
| detectable/src/main/java/com/blackduck/integration/detectable/detectables/pnpm/lockfile/process/PnpmLockYamlParserv5.java | Warn when packages is missing for v5 parsing paths. |
| detectable/src/main/java/com/blackduck/integration/detectable/detectables/pnpm/lockfile/process/PnpmLockYamlParser.java | Warn when packages is missing for v6+ parsing paths. |
| detectable/src/main/java/com/blackduck/integration/detectable/detectables/pnpm/lockfile/process/PnpmLockYamlParserInitial.java | Update v5 vs v6+ detection via lockfileVersion validation; handle empty file / null version. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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
pnpm scans were failing when the lockfile had no packages or dependencies instead of completing with an empty BOM.
Allow scan to complete with an empty BOM when no packages or dependencies are present in the lockfile.
Fix v5 lockfile detection by replacing exception-based fallback with lockfileVersion result validation. Previously, setSkipMissingProperties(true) silently suppressed the expected ConstructorException, causing v5 lockfiles to fail with a misleading error.
Add graceful handling for empty lock files and null lockfileVersion.