docs(conan): handle list-valued license in make_fossa_deps_conan#1719
Conversation
Conan recipes may declare `license` as either a single string ("MIT") or a
list/tuple of strings (["MIT", "Apache-2.0"]). Conan 2's `conan graph info
-f json` preserves that shape (ConanFile.serialize does
`list(self.license)` when it is not a string), so the script could emit a
YAML array into the fossa-deps `license` field, which must be a String:
Error in $['custom-dependencies'][N].license:
parsing Text failed, expected String, but encountered Array
license_of now normalizes any shape into a single string: a string passes
through, a list/tuple is joined into one SPDX expression via
MULTI_LICENSE_JOINER (" AND " by default), and empty/None becomes None.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
One of our users reported this error and this PR fixes it: |
WalkthroughThis PR updates the Conan walkthrough script to normalize license metadata from recipe objects. A new 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/walkthroughs/make_fossa_deps_conan.py`:
- Around line 110-115: The documentation is good but should explicitly advise
uncertainty consult legal; update the comment above the MULTI_LICENSE_JOINER
constant to add one short sentence recommending teams consult their
legal/compliance group if they're unsure whether multiple licenses should be
joined with " AND " (conjunctive) or " OR " (disjunctive), keeping the existing
rationale and default unchanged and ensuring the new note mentions
MULTI_LICENSE_JOINER so readers can find the setting to change if needed.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Organization UI (inherited)
Review profile: ASSERTIVE
Plan: Pro
Run ID: 0a31d902-15e1-4479-95ae-eca344318f01
📒 Files selected for processing (1)
docs/walkthroughs/make_fossa_deps_conan.py
| # Conan recipes may declare `license` as a single string ("MIT") or as a list/tuple of | ||
| # strings (["MIT", "Apache-2.0"]). The fossa-deps `license` field must be a single string, | ||
| # so a list is joined into one SPDX expression. We use " AND " (every license's obligations | ||
| # apply) as the conservative default; change MULTI_LICENSE_JOINER to " OR " if your packages | ||
| # are dual-licensed (consumer's choice). | ||
| MULTI_LICENSE_JOINER = " AND " |
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial | ⚡ Quick win
Clear documentation and sensible default.
The constant name is descriptive, and the comment clearly explains the normalization rationale and the AND vs OR trade-off. The conservative default (" AND ") is appropriate when license obligations stack.
Optional: Consider adding a note that projects unsure whether their multi-license packages are conjunctive (AND) or disjunctive (OR) should consult their legal/compliance team before changing the joiner.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@docs/walkthroughs/make_fossa_deps_conan.py` around lines 110 - 115, The
documentation is good but should explicitly advise uncertainty consult legal;
update the comment above the MULTI_LICENSE_JOINER constant to add one short
sentence recommending teams consult their legal/compliance group if they're
unsure whether multiple licenses should be joined with " AND " (conjunctive) or
" OR " (disjunctive), keeping the existing rationale and default unchanged and
ensuring the new note mentions MULTI_LICENSE_JOINER so readers can find the
setting to change if needed.
A Conan recipe with no `license` made license_of return None, which dump()
wrote as `license: null`. fossa-deps requires a String for custom
dependencies, so this failed with:
Error in $['custom-dependencies'][N].license:
parsing Text failed, expected String, but encountered Null
Default a missing/empty license to the SPDX "NOASSERTION" marker so the
generated fossa-deps.yml stays valid.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Problem
The Conan walkthrough script (
docs/walkthroughs/make_fossa_deps_conan.py) fails when adependency's recipe declares
licenseas a list rather than a string — common inconan-center-index (e.g.
license = ["..."]).license_of()returnednode.get("license")unchanged, so a list was written into thefossa-deps
licensefield, which must be a String.fossa analyzethen fails:This is not a Conan-version quirk — it's per-recipe. Conan 2's
conan graph info -f jsonpreserves the recipe's shape:
ConanFile.serialize()doesresult["license"] = list(self.license) if not isinstance(self.license, str) else self.license,so string-recipes yield a string and list-recipes yield an array. The script must handle both.
Fix
license_of()now normalizes any shape Conan can emit into a single string:"MIT"→"MIT"["MIT", "Apache-2.0"]→"MIT AND Apache-2.0"(joined into one SPDX expression)None/blank entries are cleaned upNone/ missing →NoneMultiple licenses are joined with
" AND "(a one-lineMULTI_LICENSE_JOINERconstant) as theconservative, SPDX-valid default — Conan's list doesn't disambiguate AND vs OR; switch to
" OR "for dual-licensed packages.Validation
license_of()against string, list, tuple, list-with-None/blanks, single-element,empty list,
None, and missing — all return the expected single string (orNone).fossa-deps.ymlfrom a graph containing array-license nodes, parsed it,and asserted every
custom-dependencies[*].licenseis a String.Notes
Changelog.mdentry added (happy to add one).license: null, which tripsthe same parser ("expected String, but encountered Null"). Can fold a fix into this PR if desired.
🤖 Generated with Claude Code