DiscoveredPackage matching query does not exist.
Traceback:
File "/app/scanpipe/pipelines/__init__.py", line 115, in execute
step(self)
File "/app/scanpipe/pipelines/scan_package.py", line 119, in build_inventory_from_scan
scancode.create_inventory_from_scan(self.project, self.scan_output_location)
File "/app/scanpipe/pipes/scancode.py", line 504, in create_inventory_from_scan
create_codebase_resources(project, scanned_codebase)
File "/app/scanpipe/pipes/scancode.py", line 398, in create_codebase_resources
package = DiscoveredPackage.objects.get(package_uid=package_uid)
File "/usr/local/lib/python3.9/site-packages/django/db/models/manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/django/db/models/query.py", line 496, in get
raise self.model.DoesNotExist(
from commoncode.resource import VirtualCodebase
scanned_codebase = VirtualCodebase("scancode-2022-06-15-04-55-57.json")
resource = scanned_codebase.get_resource('codebase/ballerina-lang-1.2.29/tool-plugins/theia/yarn.lock')
resource.for_packages # -> [None]
Input: https://github.com/ballerina-platform/ballerina-lang/archive/refs/tags/v1.2.29.tar.gz
Pipeline:
scan_packageThe culprit is the
for_packagesattribute on thecodebase/ballerina-lang-1.2.29/tool-plugins/theia/yarn.lockresource that returns a list containing aNonevalue as thepackage_uid,for_packages == [None].Nonecannot be matched in the DB thus the model.DoesNotExist exception.for_packagesvalue is generated and needs to be fixed.package_uidfield is not enforced to be unique in a project, also it is not indexed at the moment and it should as the code now heavily relies on it to fetch DiscoveredPackage instances https://github.com/nexB/scancode.io/blob/main/scanpipe/models.py#L1729