fix: evaluate combined license strings per component in the license check - #95
Merged
Merged
Conversation
…heck Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
JarbasAl
marked this pull request as ready for review
September 2, 2026 00:01
This was referenced Sep 2, 2026
Closed
JarbasAl
added a commit
that referenced
this pull request
Sep 2, 2026
The combined-license-detection step added in #95 defines FAIL_LICENSES and EXCLUDE_LICENSES as env vars but reads them as bare Python names, raising NameError: name 'FAIL_LICENSES' is not defined in every caller repo's license_check job. Read them via os.environ.get(), matching how the rest of the script accesses its env vars. Reproduced locally: extracting the inline script and running it with FAIL_LICENSES/EXCLUDE_LICENSES set as env vars (no read of the bare name) raises NameError before the fix and exits 0 after. Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
license-check.ymlclassifies each dependency by matching regexes against its whole license string, andexclude_licenses(default^Mozilla Public License.*) is anchored at the start of that whole string. A package that reports a COMBINED license — e.g. orjson'sApache Software License, MIT License, Mozilla Public License 2.0 (MPL 2.0)— starts with "Apache", not "Mozilla", so the exclude regex never matches even though the only non-permissive component (MPL) is exactly what it is meant to allow. The dependency lands inWeakCopyleftand the job fails, even when every actual component license is permitted.This was live on
LeMetadatarr/py-music-assistant'slicense_checkjob (its only failing job, pinned to an oldergh-automations@devref, before orjson was added to the central per-package whitelist here). orjson is already whitelisted by name in the current central list (PR #86), which sidesteps this specific case — but the underlying bug is generic: any package with a combined license string and a repo-specificexclude_licensespattern hits the same anchoring failure, and the central whitelist can't be extended forever for every future combined-license package.The fix
Added a step,
Detect combined-license packages safe by component, that runs before the exclude regex is built:Licensefield, split it into components only when it actually contains more than one (comma/AND/OR separated) — a single-license string is skipped entirely and falls through to the existing pilosus check exactly as before.pip_license_checker.license), same precedence: NetworkCopyleft > StrongCopyleft > WeakCopyleft > Permissive > Other.fail_licensesmust be matched by the caller'sexclude_licensesregex (re.search, evaluated against that component alone — not the whole string) for the package to be considered safe.Compatibility
Single-license strings are untouched: the new step only acts when a
Licensefield splits into 2+ components, so a currently-passing (or currently-failing) repo with plain single-license dependencies sees no change in outcome. Verified locally against three cases:Apache Software License, MIT License, Mozilla Public License 2.0 (MPL 2.0)) with the defaultexclude_licenses→ now excluded (previously failed).MIT Licensestring → fewer than 2 components, step is a no-op, behaves exactly as before.MIT License, GNU General Public License v3 (GPLv3)) against the defaultexclude_licenses→ still NOT excluded, still fails as it should.(Local harness used to check this, not committed — a standalone script reproducing the three cases above with the same classifier code as the workflow step.)
YAML validated with
python3 -c "import yaml; yaml.safe_load(open('.github/workflows/license-check.yml'))".