Problem
Supply Chain scans fail to parse valid yarn.lock entries using Yarn's patch protocol when they use optional dependency syntax. This results in reporting 0 dependencies for the NPM ecosystem.
Error Message
Failed to parse yarn.lock at 39339:1 - expected one of ['"", 'EOF']
Example Failing Entry
? "resolve@patch:resolve@npm%3A>=1.9.0#optional!builtin<compat/resolve>,
resolve@patch:resolve@npm%3A^1.1.5#optional!builtin<compat/resolve>,
..."
Root Cause
The yarn.lock parser does not handle:
- Optional dependency syntax:
? "package@version"
- URL-encoded npm prefix:
npm%3A (equivalent to npm:)
- Multi-line comma-separated patch protocol entries
Solution
Files to modify:
cli/src/semdep/parsers/yarn.py
cli/tests/default/e2e-other/parsers/test_yarn.py
Changes needed:
- Support optional dependency prefix in both Yarn v1 and v2/3 parsers
- Handle URL-encoded
npm%3A in remove_npm_prefix function
- Add comprehensive tests for optional dependencies with patch protocol
Testing
A complete patch with fix and tests is available in branch cursor/fix-yarn-patch-protocol-parsing-8907. The patch:
- ✅ Passes all 26 existing yarn parser tests
- ✅ Adds 2 new tests for optional dependency scenarios
- ✅ Successfully parses the failing entry from customer reports
Links
Impact: This affects paid customers running Supply Chain scans on Yarn-based projects that use patch protocol.
Problem
Supply Chain scans fail to parse valid
yarn.lockentries using Yarn's patch protocol when they use optional dependency syntax. This results in reporting 0 dependencies for the NPM ecosystem.Error Message
Example Failing Entry
Root Cause
The yarn.lock parser does not handle:
? "package@version"npm%3A(equivalent tonpm:)Solution
Files to modify:
cli/src/semdep/parsers/yarn.pycli/tests/default/e2e-other/parsers/test_yarn.pyChanges needed:
npm%3Ainremove_npm_prefixfunctionTesting
A complete patch with fix and tests is available in branch
cursor/fix-yarn-patch-protocol-parsing-8907. The patch:Links
Impact: This affects paid customers running Supply Chain scans on Yarn-based projects that use patch protocol.