BUG: Improve Package from PurlDB failures
維護者通常 1 天內回覆
@tdruez 已經在處理了。
開始於 2025年5月5日。
評估
這個 Issue 還沒有評估資料。
描述
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.
- 主要語言
- Python
- 星號
- 52
- 分支
- 30
- 平均合併
- 4 小時 57 分鐘
- 30 天內合併 PR
- 21
環境準備
- 提供 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
aboutcode-org/dejacode 的其他 Issue
-
DOC: Document workflow between ScanCode.io and DejaCode可能已有人在做 @tdruez 於 1 天前認領。 未關閉documentation
難度 3/5 1-2 天 新手友好度 55/100
aboutcode-org/dejacode#606 · 2 則留言 ·
維護者通常 1 天內回覆
-
難度 4/5 3-5 天 新手友好度 45/100
aboutcode-org/dejacode#603 ·
維護者通常 1 天內回覆
-
design needed enhancement
難度 3/5 1-2 天 新手友好度 62/100
aboutcode-org/dejacode#561 · 3 則留言 ·
維護者通常 1 天內回覆
-
Enhancement request: Refine License Category - Copyleft Limited可能重新可做 @hesa 於 119 天前認領,目前沒有進行中的 PR。 未關閉design needed enhancement
aboutcode-org/dejacode#499 · 13 則留言 · 已指派 3 人 ·
維護者通常 1 天內回覆
-
BUG: Product overview page splits product with many versions across pages可能重新可做 關聯的 PR 已關閉且未合併。 未關閉bug design needed enhancement
難度 3/5 1-2 天 新手友好度 45/100
aboutcode-org/dejacode#460 ·
維護者通常 1 天內回覆
查看 aboutcode-org/dejacode 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 70/100
pydantic/pydantic-ai#12091 ·
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 88/100
維護者通常 1 天內回覆
-
CSS enhancement good first issue
難度 2/5 1-3 小時 新手友好度 70/100
pychess/pychess-variants#2448 ·
維護者通常 1 天內回覆
-
Bump locked PyTensor so Apple clang 21 does not pass -ld64可能已有人在做 @drbenvincent 今天認領。 未關閉bug dev ops
難度 2/5 1-3 小時 新手友好度 70/100
維護者通常 2 天內回覆
-
ai_p2 bug comp-datalake
難度 2/5 1-3 小時 新手友好度 85/100
ClickHouse/ClickHouse#128306 · 1 則留言 ·
維護者通常 1 天內回覆