yarn.lock v1 with a scoped alias of an unscoped package yields no packages and no error

オープン 初心者向け
#5,466 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

@Shubham-dev-stack がすでに取り組んでいます。

2026年11月12日 から。

  • #5470 @Shubham-dev-stack による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
74/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
backend

調査の方向性

src/packagedcode/npm.py の、@ 文字を数えるアサーション付近にある YarnLockV1Handler.parse を読みます。提供された、スコープなしパッケージのスコープ付きエイリアスで失敗を再現し、近くにある Yarn v1 の解析テストを調べて、どこにカバレッジを追加するか特定します。解析エラーなしでロックファイルからパッケージと依存関係のデータが得られれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Description

In a Yarn v1 yarn.lock, an alias whose own name is scoped and whose target is not scoped has three @:

"@jest/react-is-18@npm:react-is@^18.3.1":
  version "18.3.1"
  resolved "https://registry.yarnpkg.com/react-is/-/react-is-18.3.1.tgz#..."

YarnLockV1Handler.parse asserts that a requirement starting with @ has two @ (a scoped package) or four (a scoped alias of a scoped package):

if req.startswith('@'):
    # 2 = package, 4 = alias
    assert req.count('@') in [2, 4]

With three, the parsing fails with an AssertionError at src/packagedcode/npm.py line 1063 and the whole lockfile is lost. Through the CLI the scan completes with no package data, no dependencies and no scan error for the file.

In a sample of 6 Yarn v1 lockfiles from well-known projects, 2 fail this way (webpack/webpack and GoogleChrome/lighthouse), both on @jest/react-is-18@npm:react-is@^18.3.1 and @jest/react-is-19@npm:react-is@^19.2.5.

How To Reproduce
  1. Download yarn.lock from https://github.com/webpack/webpack at commit 71338e24bc.
  2. Run scancode --package --json-pp out.json yarn.lock
  3. In out.json, package_data is empty for the file, dependencies is empty and scan_errors is empty.

Calling packagedcode.npm.YarnLockV1Handler.parse() on the file directly shows the AssertionError.

System configuration
  • macOS (Apple Silicon)
  • scancode-toolkit 32.5.0; the same code is on develop at e423b48a1
  • installed with pip, Python 3.12
主要言語
Python
スター
2.7k
フォーク
871
平均マージ
1日 10時間
マージ済み PR(30日)
3

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

aboutcode-org/scancode-toolkit のほかの issue

aboutcode-org/scancode-toolkit の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。