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

Đang mở Phù hợp với người mới
#5,449 4 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

@Anbarasu2410 đang làm issue này rồi.

Từ ngày 9/11/2026.

  • #5453 của @Anbarasu2410 — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
82/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
backend

Hướng nghiên cứu

Bắt đầu tại src/packagedcode/npm.py, gần dòng 757 được nhắc đến, và kiểm tra cách file_references được tạo cho các dependency trong package-lock.json. Tái hiện bằng lệnh trong issue, sau đó cập nhật đầu ra mong đợi trong tests/packagedcode/data/npm/package-lock-v2/package-lock.json-expected nếu kết quả có danh sách phẳng như mong đợi. Hoàn tất khi cả năm dependency đều có danh sách file_references phẳng và đầu ra tái hiện khớp với fixture.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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
Ngôn ngữ chính
Python
Star
2.7k
Fork
871
Merge trung bình
1 ngày 10 giờ
Pull request đã merge (30 ngày)
3

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của aboutcode-org/scancode-toolkit

Tất cả issue của aboutcode-org/scancode-toolkit

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.