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

Open Beginner friendly
#84 0 comments 0 reactions 0 assignees View on GitHub

@Mirochill is already working on this.

Since May 25, 2026.

  • #108 by @Mirochill — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
62/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
python
Domain
tooling

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:

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=[])
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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from aboutcode-org/commoncode

All issues in aboutcode-org/commoncode

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.