Skip to content

Idetect 5146 - fix(pnpm): allow scan to complete when lockfile has no dependencies#1796

Open
bd-spratikbharti wants to merge 5 commits into
masterfrom
IDETECT-5146
Open

Idetect 5146 - fix(pnpm): allow scan to complete when lockfile has no dependencies#1796
bd-spratikbharti wants to merge 5 commits into
masterfrom
IDETECT-5146

Conversation

@bd-spratikbharti

Copy link
Copy Markdown
Collaborator

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.

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.

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 packages is 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 lockfileVersion indicates v6+, and add handling for empty lockfiles / null lockfileVersion.

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.

bd-spratikbharti and others added 2 commits June 23, 2026 11:48
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.

2 participants