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

オープン 初心者向け
#84 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

@Mirochill がすでに取り組んでいます。

2026年5月25日 から。

  • #108 @Mirochill による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
62/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
python
領域
tooling

調査の方向性

src/commoncode/resource.py の 791-792 行付近と 908-918 行付近から始め、次に scancode/plugin_ignore.py の 121 行目を確認します。提供されている scancode の再現手順を systemd-stable に対して実行し、parent が None であるリソースの削除が、報告された AttributeError なしに完了することを確認します。

索引モデルが issue の本文から書いたものです。

説明

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=[])
主要言語
Python
スター
4
フォーク
25
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

aboutcode-org/commoncode のほかの issue

aboutcode-org/commoncode の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。