aboutcode-org / aboutcode-org/commoncode

Consider that Resource.parent can be None when removing resources from the codebase

Đang mở
#84 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Python
Star
4
Fork
23
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

scancode version: 4b57a7fe86
commoncode version: 32.2.1
python version: 3.13
os: linux

The problematic code:

https://github.com/aboutcode-org/commoncode/blob/aba7c1bdce1477b6b44c4afabd747bd81d9654cf/src/commoncode/resource.py#L908-L918

parent can be None:

https://github.com/aboutcode-org/commoncode/blob/aba7c1bdce1477b6b44c4afabd747bd81d9654cf/src/commoncode/resource.py#L791-L792

None has no `children_names` , it fails. This happens in example if the plugin_ignore of scancode trys to remove some resources from the codebase at: scancode/plugin_ignore.py(121)process_codebase()

How to reproduce:
~~~
❯ scancode --processes 10 -l -p -c -i --ignore "*/test/*" --license-score 20 --strip-root --json-pp test.json repos/git/github/systemd/systemd-stable
Setup plugins...
Collect file inventory...
ERROR: failed to run pre-scan plugin: ignore:
Traceback (most recent call last):
File "/home/jloehel/projects/github.com/aboutcode-org/scancode-toolkit/src/scancode/cli.py", line 1119, in run_codebase_plugins
plugin.process_codebase(codebase, **kwargs)
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
File "/home/jloehel/projects/github.com/aboutcode-org/scancode-toolkit/src/scancode/plugin_ignore.py", line 121, in process_codebase
remove_resource(resource)
~~~~~~~~~~~~~~~^^^^^^^^^^
File "/home/jloehel/projects/github.com/aboutcode-org/scancode-toolkit/.venv/lib64/python3.13/site-packages/commoncode/resource.py", line 911, in remove_resource
parent.children_names.remove(resource.name)
^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'children_names'
...
~~~

Resource is:
~~~
ScannedResource(path='systemd-stable/test/fuzz/fuzz-unit-file/dev-mapper-fedora_krowka/x2dswap.swap', is_file=True, is_filtered=False, detected_license_expression=None, detected_license_expression_spdx=None, license_detections=[], license_clues=[], percentage_of_license_text=0, copyrights=[], holders=[], authors=[])
~~~

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.