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

Aperta Adatta ai principianti
#5,466 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

@Shubham-dev-stack ci sta già lavorando.

Dal 12/11/2026.

  • #5470 di @Shubham-dev-stack — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
74/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
backend

Direzione di ricerca

Leggi YarnLockV1Handler.parse in src/packagedcode/npm.py, vicino all’asserzione che conta i caratteri @. Riproduci l’errore con l’alias scoped fornito di un pacchetto non scoped, poi esamina i test di parsing di Yarn v1 nelle vicinanze per individuare dove aggiungere la copertura. Il lavoro è completato quando il file di lock fornisce i dati dei pacchetti e delle dipendenze senza errori di parsing.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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
Lingua principale
Python
Stelle
2.7k
Fork
871
Merge medio
1g 10h
PR unite (30g)
3

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di aboutcode-org/scancode-toolkit

Tutte le issue di aboutcode-org/scancode-toolkit

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.