Four silent bugs: IsRequiredPhrase.license_expression returns None, find_in_path ignores later PATH changes, duplicate dict keys override license mappings
Maintainers usually reply within 2 days
Assessment
- Difficulty
- 2/5
- Estimated time
- Half a day
- Newbie friendliness
- 65/100
Research direction
Start with item 1 in src/licensedcode/required_phrases.py near line 205, where the license_expression property evaluates self.rule.license_expression without returning it, and check how other properties in that class read their values. Item 2 is in src/commoncode/command.py around line 319, where find_in_path evaluates searchable_paths() at import time. Run a small script that changes PATH after import to reproduce it. Item 3 needs a maintainer decision on the intended values in src/packagedcode/rubygems.py and src/packagedcode/alpine.py, so leave it alone unless the thread settles it. Done means the fixed properties return the expected values and the relevant tests pass.
Written by the indexing model from the issue text.
Description
Summary
A static scan of src/ found four bugs that fail silently (no exception).
Each was reproduced with a small standalone script.
1. IsRequiredPhrase.license_expression always returns None
src/licensedcode/required_phrases.py (~line 205):
@property
def license_expression(self):
self.rule.license_expression # missing `return`
Repro: IsRequiredPhrase(rule=<rule with license_expression="mit">, ...) .license_expression returns None.
Fix: return self.rule.license_expression.
2. find_in_path ignores PATH changes made after import
src/commoncode/command.py (~line 319):
def find_in_path(filename, searchable_paths=searchable_paths()):
The default is evaluated once at import time, so PATH changes made afterwards
are ignored. The parameter also shadows the searchable_paths() function.
Repro: import the module, then prepend a directory containing mytool to
os.environ["PATH"]. find_in_path("mytool") returns None, but
find_in_path("mytool", searchable_paths()) returns the path.
Fix: default to None and call searchable_paths() inside the function.
3. Duplicate dict keys with conflicting values silently override mappings
Python keeps only the last value, so the earlier entries are dead.
src/packagedcode/rubygems.py(LICENSES_MAPPING, lines 679-680):
'LGPL'maps to'lgpl'and then to'lgpl-2.0-plus'.src/packagedcode/alpine.py(DECLARED_TO_SPDX):'as-is'(lines 1619, 1701):licenseref-scancode-free-unknownvs
licenseref-scancode-unknown-license-reference'custom:tu-berlin-2.0'(lines 1690, 1715):
licenseref-scancode-unknown-license-referencevstu-berlin-2.0
The maintainers should decide which value is intended and remove the other.
4. Duplicate key in default ignores (harmless, cleanup)
src/commoncode/ignore.py lines 204-205 repeat "autogen.sh".
Environment
Found by static analysis (ruff F601, B008, B018) at commit 05a98f66.
Please verify the intended values for item 3 before changing them.
- Dominant language
- Python
- Stars
- 2.7k
- Forks
- 871
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 3
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
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/scancode-toolkit
-
yarn.lock v1 with a scoped alias of an unscoped package yields no packages and no errorPossibly taken @Shubham-dev-stack claimed this 6 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
aboutcode-org/scancode-toolkit#5466 ·
Maintainers usually reply within 2 days
-
package-lock.json dependencies report file_references as a list inside a listPossibly taken @Anbarasu2410 claimed this 9 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
aboutcode-org/scancode-toolkit#5449 · 4 comments ·
Maintainers usually reply within 2 days
-
scancode aborts when encountering a broken RPM archivePossibly taken @Ashutosh-Panda2004 claimed this 14 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
aboutcode-org/scancode-toolkit#5407 · 3 comments ·
Maintainers usually reply within 2 days
-
parse_maintainer_name_email returns empty name and wrong email when string has "@" but no angle bracketsPossibly taken @RohitSutar1823 claimed this 14 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
aboutcode-org/scancode-toolkit#5402 ·
Maintainers usually reply within 2 days
-
bug: Unreachable JSON extension and format validation in validate_input_pathPossibly taken @0Cymantek0 claimed this 38 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
aboutcode-org/scancode-toolkit#5351 · 1 comment ·
Maintainers usually reply within 2 days
All issues in aboutcode-org/scancode-toolkit
Similar issues
-
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
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
openedx/xblock-lti-consumer#765 ·
Maintainers usually reply within 1 day