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

Đang mở Phù hợp với người mới
#5,466 0 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

@Shubham-dev-stack đang làm issue này rồi.

Từ ngày 12/11/2026.

  • #5470 của @Shubham-dev-stack — đ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
74/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

Đọc YarnLockV1Handler.parse trong src/packagedcode/npm.py, gần assertion đếm các ký tự @. Tái hiện lỗi bằng alias có scope được cung cấp của một package không có scope, sau đó kiểm tra các bài kiểm thử phân tích Yarn v1 gần đó để xác định vị trí cần bổ sung coverage. Hoàn tất khi lockfile trả về dữ liệu package và dependency mà không có lỗi phân tích.

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

Mô tả

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
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.