Consider that Resource.parent can be None when removing resources from the codebase
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 62/100
Research direction
Start with src/commoncode/resource.py around lines 791-792 and 908-918, then inspect scancode/plugin_ignore.py at line 121. Run the supplied scancode reproduction against systemd-stable and confirm that removing a resource whose parent is None completes without the reported AttributeError.
Written by the indexing model from the issue text.
Description
scancode version: 4b57a7fe86
commoncode version: 32.2.1
python version: 3.13
os: linux
The problematic code:
parent can be None:
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=[])
- Dominant language
- Python
- Stars
- 4
- Forks
- 25
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from aboutcode-org/commoncode
-
Click 8.5.0: omitted boolean flags incorrectly trigger conflicting_options validationPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 3/5 1-2 days Newbie friendliness 66/100
aboutcode-org/commoncode#112 ·
-
Revisit cliutils.pyOpen
Difficulty 4/5 3-5 days Newbie friendliness 35/100
aboutcode-org/commoncode#102 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
aboutcode-org/commoncode#101 · 1 comment ·
-
mass-scan: Create library to collect a whole project version from Software HeritageMay be free again @chinyeungli claimed this 264 days ago, and no pull request is open. Open
aboutcode-org/commoncode#77 · 7 comments · 1 assignee ·
-
Fix DeprecationWarning in timeutils.py and archive.pyPossibly taken @shashank-tomar0 claimed this 10 days ago. Opengood first issue
Difficulty 3/5 1-2 days Newbie friendliness 42/100
aboutcode-org/commoncode#75 · 1 comment ·
All issues in aboutcode-org/commoncode
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
GoogleCloudPlatform/professional-services-data-validator#1899 ·
Maintainers usually reply within 4 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
mohanraj00/entelos#200 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
-
sweep
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
bketelsen/truenas-mcp#77 ·
Maintainers usually reply within 1 day
-
Console writes URL credentials to the local log, though AGENTS.md says secrets never reach diskOpen
Difficulty 1/5 Under an hour Newbie friendliness 86/100
sandbox-quantum/switch#2163 ·
Maintainers usually reply within 1 day