aboutcode-org / scancode-toolkit

:mag: ScanCode detects licenses, copyrights, dependencies by "scanning code" ... to discover and inventory open source and third-party packages used in your code. Sponsored by NLnet project https://nlnet.nl/project/vulnerabilitydatabase, the Google Summer of Code, Azure credits, nexB and others generous sponsors!
https://aboutcode.org/scancode/
2.13k stars 551 forks source link

NoneType not handled in add_referenced_license_matches_for_package #3969

Open FaberFlorian opened 1 week ago

FaberFlorian commented 1 week ago

Description

ERROR: failed to run scan plugin: packages:
Traceback (most recent call last):
  File "/scancode-toolkit/src/scancode/cli.py", line 1117, in run_codebase_plugins
    plugin.process_codebase(codebase, **kwargs)
  File "/scancode-toolkit/src/packagedcode/plugin_package.py", line 252, in process_codebase
    modified = list(add_referenced_license_matches_for_package(resource, codebase))
  File "/scancode-toolkit/src/packagedcode/licensing.py", line 144, in add_referenced_license_matches_for_package
    detections_added.extend(referenced_resource.license_detections)
AttributeError: 'NoneType' object has no attribute 'license_detections'

How To Reproduce

Reproducible by scanning lzo 2.10 with scancode v32.3.0. Worked before.

docker run -v /home/foo/bar/lzo/src:/project -v /home/foo/bar/foss-licenses/licenseData/scancode:/licenses scancode-toolkit:latest -clpieu -nnproc--strip-root --json /licenses/lzo_2.10.json /project/

AyanSinhaMahapatra commented 1 week ago

@FaberFlorian thanks for the report, I could reproduce this bug. Will add a fix soon