package-lock.json dependencies report file_references as a list inside a list

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

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

@Anbarasu2410 がすでに取り組んでいます。

2026年11月9日 から。

  • #5453 @Anbarasu2410 による — オープン

評価

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

調査の方向性

参照されている757行目付近の src/packagedcode/npm.py から始めて、package-lock.json の依存関係に対する file_references の構築方法を調べてください。Issueに記載されたコマンドで再現し、結果が想定されるフラットなリストになった場合は、tests/packagedcode/data/npm/package-lock-v2/package-lock.json-expected の期待される出力を更新してください。5つすべての依存関係にフラットな file_references リストがあり、再現結果がフィクスチャと一致したら完了です。

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

説明

bug
Description

For dependencies parsed from package-lock.json, resolved_package.file_references is a list inside a list, instead of a list of file references.

  • Expected: [{"path": "node_modules/@sindresorhus/is", ...}]
  • Actual: [[{"path": "node_modules/@sindresorhus/is", ...}]]

The cause looks like a trailing comma, which wraps the list in a tuple:
https://github.com/aboutcode-org/scancode-toolkit/blob/e423b48a1f/src/packagedcode/npm.py#L757

Code that reads file_references[0]["path"] fails with a TypeError.

The nested shape is also recorded in the expected test output, so fixing it means updating fixtures:
https://github.com/aboutcode-org/scancode-toolkit/blob/e423b48a1f/tests/packagedcode/data/npm/package-lock-v2/package-lock.json-expected#L106-L108

How To Reproduce

From the root of the repository:

scancode --package --json-pp result.json tests/packagedcode/data/npm/package-lock-v2/package-lock.json

In result.json, check dependencies[].resolved_package.file_references. All 5 dependencies have the nested list.

System configuration
  • What OS are you running on? Windows 11
  • What version of scancode-toolkit was used to generate the scan file? 33.0.0rc1, develop at e423b48a1f
  • What installation method was used to install/run scancode? Source checkout, Python 3.14.4
主要言語
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 を短くまとめたダイジェスト。