Skip to content

docs(conan): handle list-valued license in make_fossa_deps_conan#1719

Merged
cmboling merged 2 commits into
masterfrom
fix/conan-license-array
Jun 11, 2026
Merged

docs(conan): handle list-valued license in make_fossa_deps_conan#1719
cmboling merged 2 commits into
masterfrom
fix/conan-license-array

Conversation

@cmboling

Copy link
Copy Markdown
Contributor

Problem

The Conan walkthrough script (docs/walkthroughs/make_fossa_deps_conan.py) fails when a
dependency's recipe declares license as a list rather than a string — common in
conan-center-index (e.g. license = ["..."]).

license_of() returned node.get("license") unchanged, so a list was written into the
fossa-deps license field, which must be a String. fossa analyze then fails:

Error in $['custom-dependencies'][N].license:
  parsing Text failed, expected String, but encountered Array

This is not a Conan-version quirk — it's per-recipe. Conan 2's conan graph info -f json
preserves the recipe's shape: ConanFile.serialize() does
result["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)
  • tuples and lists containing None/blank entries are cleaned up
  • empty list / None / missing → None

Multiple licenses are joined with " AND " (a one-line MULTI_LICENSE_JOINER constant) as the
conservative, SPDX-valid default — Conan's list doesn't disambiguate AND vs OR; switch to
" OR " for dual-licensed packages.

Validation

  • Unit-checked license_of() against string, list, tuple, list-with-None/blanks, single-element,
    empty list, None, and missing — all return the expected single string (or None).
  • Reproduced the original failure (array → YAML list) and confirmed the fix emits a scalar String.
  • End-to-end: generated a fossa-deps.yml from a graph containing array-license nodes, parsed it,
    and asserted every custom-dependencies[*].license is a String.

Notes

  • Docs-only change to the walkthrough script; no Changelog.md entry added (happy to add one).
  • Related edge not covered here: a recipe with no license still emits license: null, which trips
    the same parser ("expected String, but encountered Null"). Can fold a fix into this PR if desired.

🤖 Generated with Claude Code

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>
@cmboling cmboling requested a review from a team as a code owner June 10, 2026 23:07
@cmboling cmboling requested a review from tjugdev June 10, 2026 23:07
@cmboling

Copy link
Copy Markdown
Contributor Author

One of our users reported this error and this PR fixes it:

Error:  An issue occurred

  *** Relevant Errors ***

      Error: parsing file: /__w/<app>/fossa-deps.yml
        Aeson exception:
        Error in $['custom-dependencies'][5].license: parsing Text failed, expected String, but encountered Array
      Support: If you believe this to be a defect, please report a bug to FOSSA support at https://support.fossa.com/, with a copy of:  /__w/<app>/fossa-deps.yml

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

This PR updates the Conan walkthrough script to normalize license metadata from recipe objects. A new MULTI_LICENSE_JOINER constant defines the default joiner (" AND ") for multi-license expressions. The license_of() function now handles three input shapes: returns None when license is missing, passes through string values unchanged, and for list/tuple licenses, filters empty items, coerces each to a string, and joins them. For unexpected license types, the function coerces the value to a string to ensure the generated YAML remains valid.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The description provides comprehensive coverage of problem, fix, validation, and notes, but omits several template sections (Overview, Acceptance criteria, Testing plan, Risks, Metrics, References, and Checklist). Fill in missing template sections: provide Overview/intent summary, Acceptance criteria for user impact, concrete Testing plan steps, Risks assessment, Metrics tracking info, issue/ticket References, and confirm Checklist items.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: normalizing list-valued license fields in the Conan walkthrough script.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between faf8907 and b63dbd3.

📒 Files selected for processing (1)
  • docs/walkthroughs/make_fossa_deps_conan.py

Comment on lines +110 to +115
# 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 "

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 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>
@cmboling cmboling merged commit 98130f3 into master Jun 11, 2026
19 checks passed
@cmboling cmboling deleted the fix/conan-license-array branch June 11, 2026 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants