DRAFT: Fix Yarn Detector Crash on Yarn 4 Protocol Specifier - #1872
Draft
zahidblackduck wants to merge 2 commits into
Draft
zahidblackduck wants to merge 2 commits into
zahidblackduck wants to merge 2 commits into
Conversation
zahidblackduck
marked this pull request as draft
September 11, 2026 09:42
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.
JIRA Ticket
IDETECT-5308
Description
This pull request fixes a crash in the Yarn detector when scanning Yarn 4 (Berry) projects that contain
npm:protocol specifiers. Previously, detect scan would threw aStringIndexOutOfBoundsExceptionduring extraction, causing the entire scan to fail.Root Cause
Yarn 4 encodes an "any version" dependency as
"npm:"(empty after the colon). The header section parser strips the trailing:from@package@npm:lockfile header tokens viaremoveEnd(), which leaves the stored key as"npm"rather than"", causing a resolution map miss. The graph builder falls back to theLazyIdpath, which produces an empty version string.VersionUtility.mustUpgradeEqual()then callsversion.substring(1)without guarding against an empty input, throwingStringIndexOutOfBoundsException.Fix
mustUpgradeEqual(): when the version string is empty (Yarn 4"npm:"any-version specifier), return the highest available resolved version, matching the existing behavior for Yarn 1's"*"specifierYarnLockV4NpmProtocolSpecifierTestcovering Yarn 4 header variants.N.B: This pull request is meant to be shipped with detect
12.2.0