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

Offen Anfängerfreundlich
#5,466 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

@Shubham-dev-stack arbeitet bereits daran.

Seit 12.11.2026.

  • #5470 von @Shubham-dev-stack — offen

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
74/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
python
Bereich
backend

Rechercherichtung

Lies YarnLockV1Handler.parse in src/packagedcode/npm.py im Bereich der Assertion, die @-Zeichen zählt. Reproduziere den Fehler mit dem bereitgestellten Scoped-Alias eines nicht gescopten Pakets und sieh dir anschließend die Tests für das Parsing von Yarn v1 in der Nähe an, um herauszufinden, wo die Abdeckung ergänzt werden soll. Fertig ist die Arbeit, wenn die Lockfile Paket- und Abhängigkeitsdaten ohne Parsing-Fehler liefert.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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
Vorherrschende Sprache
Python
Sterne
2.7k
Forks
871
Ø Merge
1 T. 10 Std.
Gemergte PRs (30 T.)
3

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus aboutcode-org/scancode-toolkit

Alle Issues in aboutcode-org/scancode-toolkit

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.