Skip to content

fix(pkgmetadata): raise ValueError when no classifier maps to SPDX - #1374

Open
rd4398 wants to merge 1 commit into
python-wheel-build:mainfrom
rd4398:fix-1372
Open

rd4398 wants to merge 1 commit into
python-wheel-build:mainfrom
rd4398:fix-1372

Conversation

@rd4398

@rd4398 rd4398 commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

_trove_to_spdx() skipped every classifier absent from _TROVE_SPDX, leaving trove_spdx empty and calling _parse_spdx(""), which parses to None and raised AttributeError on None.simplify().

Since that is not a ValueError, license_from_metadata_values() could not catch it and fall back. It now raises ValueError when no classifier maps to SPDX, restoring the documented behavior so callers can fall back to NOASSERTION.

Closes: #1372

`_trove_to_spdx()` skipped every classifier absent from `_TROVE_SPDX`,
leaving `trove_spdx` empty and calling `_parse_spdx("")`, which parses to
`None` and raised `AttributeError` on `None.simplify()`. Since that is not
a `ValueError`, `license_from_metadata_values()` could not catch it and fall
back. It now raises `ValueError` when no classifier maps to SPDX, restoring
the documented behavior so callers can fall back to `NOASSERTION`.

Closes: python-wheel-build#1372

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Rohan Devasthale <rdevasth@redhat.com>
@rd4398
rd4398 requested a review from a team as a code owner October 15, 2026 19:50
@coderabbitai

coderabbitai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: python-wheel-build/fromager/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: cb75e581-c3a5-49a8-99da-05ce9ad7ab2a
📥 Commits

Reviewing files that changed from the base of the PR and between f699f2f and 81056e3.

📒 Files selected for processing: 2
  • src/fromager/pkgmetadata/pep639.py
  • tests/test_pkgmetadata.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Walkthrough

When no classifier maps to an SPDX expression, _trove_to_spdx now raises ValueError instead of passing an empty expression to the parser. Tests add unmapped classifier cases and a case combining a Python-version classifier with an ambiguous BSD license classifier.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 81056

The change reports unmapped classifier metadata as a license-detection error while preserving tested mapped results. No actionable merge risk remains.

Pre-merge checks: Passed 4
Check name Status Explanation
Description check Passed The description clearly explains the empty SPDX expression failure, the resulting exception, and the ValueError fix. It matches the changeset and PR objective.
Title check Passed The title clearly and concisely describes the main change: raising ValueError when no classifier maps to an SPDX expression.
Linked Issues check Passed Issue #1372 requires a ValueError-compatible failure when metadata contains no usable license. At the reviewed head, _trove_to_spdx() raises `ValueError("no classifier maps to a SPDX license express…
Out of Scope Changes check Passed The reviewed changes are limited to the classifier error handling in src/fromager/pkgmetadata/pep639.py and regression cases in tests/test_pkgmetadata.py. Both changes directly support issue #1372…
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@rd4398
rd4398 requested a review from mprpic October 15, 2026 19:50
@mergify mergify Bot added the ci label Oct 15, 2026

@mprpic mprpic 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.

LGTM!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: license_from_metadata() raises AttributeError when no classifier maps to SPDX

2 participants