Skip to content

fix: raise correct exception on invalid license - #1219

Merged
henryiii merged 1 commit into
pypa:mainfrom
trail-of-forks:ft/raise-invalid-license
Jun 11, 2026
Merged

henryiii merged 1 commit into
pypa:mainfrom
trail-of-forks:ft/raise-invalid-license

Conversation

@facutuesca

Copy link
Copy Markdown
Contributor

The SPDX license spec says that a valid license-id can have a + suffix:

MIT
MIT+

But this does not apply to license-ref:

LicenseRef-Foo  # valid
LicenseRef-Foo+  # not valid

Currently, during canocalization, if we encounter LicenseRef-Foo+, we get an unhandled KeyError exception. This PR fixes that by instead checking for a suffix and raising the correct InvalidLicenseExpression exception instead.

cc @miketheman

@facutuesca
facutuesca force-pushed the ft/raise-invalid-license branch from 2036029 to 9cf619e Compare June 4, 2026 14:09
@facutuesca
facutuesca force-pushed the ft/raise-invalid-license branch from 9cf619e to 1d27872 Compare June 6, 2026 00:20

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

This looks correct according to the spec.

@henryiii

Copy link
Copy Markdown
Contributor

We've removed the requirement that branches be updated (using the newer "always suggest updating" setting instead, so I can now merge without waiting for a synchronized rebase. :)

@henryiii henryiii changed the title Raise correct exception on invalid license fix: raise correct exception on invalid license Jun 11, 2026
@henryiii
henryiii merged commit 9cef9d0 into pypa:main Jun 11, 2026
58 checks passed
@facutuesca
facutuesca deleted the ft/raise-invalid-license branch June 11, 2026 21:26
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