BUG: Improve Package from PurlDB failures
I maintainer di solito rispondono entro 1 giorno
@tdruez ci sta già lavorando.
Dal 5/5/2025.
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
Extracted from https://github.com/aboutcode-org/dejacode/issues/295#issuecomment-2824782627
Running "Improve Package from PurlDB" fails with duplicate key value violates unique constraint"component_catalog_packag_dataspace_id_type_namesp_c6620419_uniq"DETAIL:Key(dataspace_id,type,namespace,name,version,qualifiers,subpath,download_url,filename)=(3,npm,,parse-json,4.0.0,,,https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz,parse-json-4.0.0.tgz)alreadyexists. since assigning the download_url would make it a fully duplicate package.
Attempting to enhance the package in the product with data from PurlDB fails, because assigning the download URL would violate the uniqueness constraint that covers dataspace_id, type, namespace, name, version, qualifiers, subpath, download_url, and filename
This is a corner case where the data pulled from the PurlDB can trigger a "unique constraint" violation when applied to a package.
Context
PURL from a CycloneDX SBOM: pkg:npm/[email protected]
Note that in that data source context, no download_url is provided.
"There are multiple entries in the PurlDB for this Package." -> 4 results in the PurlDB for this PURL.
https://public.purldb.io/api/packages/?purl=pkg:npm/[email protected]
[
{
"uuid": "d1eb90f6-5115-49b8-a5f8-782e948cbd3d",
"filename": "parse-json-4.0.0.tgz",
"purl": "pkg:npm/[email protected]",
"type": "npm",
"name": "parse-json",
"version": "4.0.0",
"download_url": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz",
"sha1": "be35f5425be1f7f6c747184f98a788cb99477ee0",
"package_content": null,
"package_sets": []
},
{
"uuid": "bd3c0519-50d6-47a9-b01a-d3241e0ef641",
"filename": null,
"package_sets": [],
"purl": "pkg:npm/[email protected]",
"type": "npm",
"namespace": "",
"name": "parse-json",
"version": "4.0.0",
"download_url": "https://registry.npmjs.com/parse-json/-/parse-json-4.0.0.tgz",
"sha1": "be35f5425be1f7f6c747184f98a788cb99477ee0",
"package_sets": []
},
{
"uuid": "0ff3a534-5570-4289-8560-6e46bb3bad4f",
"filename": "parse-json-4.0.0.tgz",
"purl": "pkg:npm/%40types/[email protected]",
"type": "npm",
"namespace": "@types",
"name": "parse-json",
"version": "4.0.0",
"download_url": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz",
"package_content": null,
"package_sets": [
{
"uuid": "721da624-9d02-401f-82b6-46142449635d",
"packages": [
"https://public.purldb.io/api/packages/0ff3a534-5570-4289-8560-6e46bb3bad4f/",
"https://public.purldb.io/api/packages/ec74c5e3-676b-489a-a059-4176bdfe6ea8/"
]
}
]
},
{
"uuid": "680f4c25-68b3-4e21-8c16-6db2a822e752",
"filename": null,
"purl": "pkg:npm/%40types/[email protected]",
"type": "npm",
"namespace": "@types",
"name": "parse-json",
"version": "4.0.0",
"download_url": "https://registry.npmjs.com/@types/parse-json/-/parse-json-4.0.0.tgz",
"package_content": null,
"package_sets": [
{
"uuid": "c4608309-c909-4a86-bf75-c3363d50bf98",
"packages": [
"https://public.purldb.io/api/packages/680f4c25-68b3-4e21-8c16-6db2a822e752/",
"https://public.purldb.io/api/packages/ec74c5e3-676b-489a-a059-4176bdfe6ea8/"
]
}
],
}
]
- Since the provided purl has no namespace, ie:
pkg:npm/[email protected], the entries forpkg:npm/%40types/[email protected]should not be returned - The default ordering of the results should be by each PURL field. From
packageurl.contrib.django.models.PackageURLQuerySetMixin.order_by_package_url:
PACKAGE_URL_FIELDS = ("type", "namespace", "name", "version", "qualifiers", "subpath")
def order_by_package_url(self):
"""Order by Package URL fields."""
return self.order_by(*PACKAGE_URL_FIELDS)
- The 2 entries for
pkg:npm/[email protected]are the same, thesha1id equal, the only difference is the domain in thedownload_url:npmjs.orgvsnpmjs.com. The issue in the DejaCode context using the PurlDB is which one of those package should we use?
An approach could be to take the common fields values from the multiple entries. In this case, as the only know value on the DejaCode side ispkg:npm/[email protected], we could ignore the download_url and hash and import everything that is shared across the PurlDB records.
TODO (Fix) in DejaCode
-
The task should not break, any issues happening during the "Improve Packages from PurlDB" should be properly handled and logged during the
improve_packages_from_purldbtask. -
Using data pulled from PurlDB onto a package should not raise a unique constraint violation.
- Lingua principale
- Python
- Stelle
- 52
- Fork
- 30
- Merge medio
- 4h 57m
- PR unite (30g)
- 21
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di aboutcode-org/dejacode
-
DOC: Document workflow between ScanCode.io and DejaCodeForse già presa @tdruez l’ha presa 2 giorni fa. Apertadocumentation
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
aboutcode-org/dejacode#606 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
aboutcode-org/dejacode#603 ·
I maintainer di solito rispondono entro 1 giorno
-
design needed enhancement
Difficoltà 3/5 1-2 giorni Idoneità per principianti 62/100
aboutcode-org/dejacode#561 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Enhancement request: Refine License Category - Copyleft LimitedForse di nuovo libera @hesa l’ha presa 120 giorni fa e non c’è nessuna pull request aperta. Apertadesign needed enhancement
aboutcode-org/dejacode#499 · 13 commenti · 3 assegnatari ·
I maintainer di solito rispondono entro 1 giorno
-
BUG: Product overview page splits product with many versions across pagesForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Apertabug design needed enhancement
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
aboutcode-org/dejacode#460 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di aboutcode-org/dejacode
Issue simili
-
ReadQwen3PaperTask5 rejects correct answers that differ only in order, case, or underscore formForse già presa @Kingpython123 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
Tongyi-MAI/MobileWorld#72 ·
-
_threads/application: Update typing annotations using `pyupgrade --py311-plus`Forse già presa @gudnimg l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Health probes return 401 when authentication is enabled and the API is served under /orbForse già presa @fgogolli l’ha presa oggi. Apertaarea: api priority: p2 size: S type: bug
Difficoltà 2/5 Mezza giornata Idoneità per principianti 75/100
finos/open-resource-broker#704 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
BCDA-APS/polar-bits#93 ·
-
bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
GoogleCloudPlatform/gce-rescue#218 ·
I maintainer di solito rispondono entro 2 giorni