1. Introduction
Package manifests, Python core metadata (PEP 639 [3]), crates, SBOMs and dependency-review gates all carry license information as SPDX license expressions such as MIT OR Apache-2.0 or GPL-2.0-or-later WITH Classpath-exception-2.0. Coding agents now write these strings when they scaffold packages, and compliance tools read them to decide whether a dependency may ship. Annex B of the SPDX Specification [1] defines the grammar in ABNF and adds prose rules. Operators may be written all upper case or all lower case. License identifiers match case-insensitively, but the LicenseRef- prefix does not. + follows a license identifier with no space. WITH takes an exception or an AdditionRef- on its right. WITH binds tighter than AND, which binds tighter than OR. The identifiers come from the SPDX License List [2], which keeps deprecated identifiers (for example GPL-2.0) marked as deprecated rather than removing them. We ask: given byte-identical expression strings, do widely used parsers accept the same strings and read them the same way?
2. Related work
Differential testing [4] has been applied to many input languages, but we found no published cross-parser matrix for SPDX expressions. SBOM studies measure tools one level up. Wang et al. [5] compared six SBOM generators on 3,287 repositories and found license-field accuracy below 20%. Prado et al. [6] traced divergent SBOMs to specification ambiguities and to whether fields are populated. Neither isolates the parser that decides whether an expression is valid. LiDetector [7] infers license incompatibilities from license text, not expression syntax. The libraries document their own departures: spdx-expression-parse’s README says it allows lower- and mixed-case operators, and the Rust spdx crate has a strict and a lax mode [8, 9]. These are statements about one library each. We found no study that runs one case set through several of them.
3. Method
Subjects (public APIs, default options). (1) spdx-expression-parse 5.0.0, the current npm release. (2) spdx-expression-parse 3.0.1, the version that spdx-satisfies 6.0.1 depends on. (3) license-expression 30.4.4 (Python, AboutCode/ScanCode, also used by the Python spdx-tools), called as get_spdx_licensing().parse(expr, validate=True, strict=True). (4) packaging 26.3, packaging.licenses.canonicalize_license_expression, the PEP 639 normaliser used by Python build back ends. (5) github/go-spdx v2.8.0 spdxexp: ValidateAndNormalizeLicensesWithOptions for acceptance and normal form, ExtractLicenses for leaves, and Satisfies for probes. (6) the Rust spdx crate 0.13.6 (used by cargo-deny), Expression::parse (strict mode), with its postfix iter() for the tree and evaluate for probes. spdx-satisfies 6.0.1 supplies the npm allow-list probe. Bundled license lists: go-spdx and spdx 3.29.0, packaging 3.27.0, spdx-license-ids 3.0.24, and license-expression’s ScanCode index. Node v24.22.1, CPython 3.13.5, Go 1.27.3, rustc 1.85.1. We left out Java (no JVM on the test machine).
Cases. gen_cases.py writes 91 cases in ten groups. Basic forms (10), precedence and parentheses (10), operator case (7), identifier case (8), deprecated and unknown identifiers (9), the + operator (5), WITH operands (9), syntax and whitespace (16), LicenseRef- strings (5), and strings seen in package metadata (12). Each case carries the Annex B reading. That is either invalid or a canonical tree with same-operator chains flattened and identifiers compared case-insensitively. Four cases are open: surrounding spaces, a tab, and the document-field sentinels NONE and NOASSERTION, which lie outside the expression grammar. Seven precedence and case-mixing expressions also carry allow-list probes with the satisfied/not-satisfied answer implied by Annex B precedence.
Readings and classes (analyze.py). For spdx-expression-parse, license-expression and spdx, we render the library’s own tree. packaging and go-spdx expose no tree, so we compare acceptance and the set of leaves in their canonical string. A agrees with the reading. N accepted but rewrote an identifier to its current equivalent (for example GPL-2.0 to GPL-2.0-only). T accepted with a different meaning. R rejected a valid expression. L accepted an invalid one.
Reproduce.
git clone https://github.com/buildngrowsv/pubroot-pilots && cd pubroot-pilots
git checkout 3da72ec8733e5d49b1a92ef46e3a458cacae086f
cd spdx-expressions/js && npm ci && cd ..
python3 -m venv .venv && .venv/bin/pip install -r py/requirements.txt
PY=.venv/bin/python ./run_all.sh
Folder: https://github.com/buildngrowsv/pubroot-[REDACTED_SECRET]-expressions/
Two runs in the working tree and a third from a git archive export with fresh npm ci/pip install produced byte-identical results/ files.
4. Results
The six parsers disagreed on whether to accept 34 of 91 expressions; one more case (R05) was accepted by all but read differently. All six gave the same answer on the other 56. Class counts (A/N/T/R/L, excluding the four open cases): spdx-expression-parse 5.0.0 77/0/0/6/4, 3.0.1 75/0/0/11/1, license-expression 67/5/1/11/3, spdx 75/0/0/11/1, packaging 80/0/0/2/5, go-spdx 77/1/0/7/2. Pairwise acceptance differences ranged from 7 cases (go-spdx–spdx-expression-parse 3.0.1) to 23 (license-expression versus 3.0.1 or spdx, and go-spdx versus spdx). Precedence was not a problem. All ten precedence cases got identical trees, and every allow-list probe that ran matched the Annex B answer. The disagreements are about which strings are valid.
Identifier case (I01–I04). Annex B says MIT, Mit and mIt are the same identifier. license-expression, packaging and go-spdx accept mit and BSD-3-CLAUSE and return the canonical spelling. Both spdx-expression-parse versions and spdx reject them (Unexpected 'm' at offset 0; UnknownTerm). A lower-case identifier that passes pip’s metadata validation therefore fails npm-side and Rust-side validators.
Operator case (K01–K07). Lower-case or, and and with are valid. spdx-expression-parse 3.0.1 rejects all three, and go-spdx rejects or and and but accepts with. Mixed case (Or, aNd, With) is invalid, yet spdx-expression-parse 5.0.0, license-expression and packaging accept it, and go-spdx accepts With. Because spdx-satisfies parses with 3.0.1, its probes on K07 (MIT OR Apache-2.0 and BSD-3-Clause) raise an error instead of answering; go-spdx Satisfies errors too, while spdx answers correctly. go-spdx’s two public entry points also disagree. ValidateAndNormalizeLicensesWithOptions accepts K03 and K06, but ExtractLicenses fails on both with unknown license 'with'. For U05 it is the other way round: validation rejects Apache-1.1+ WITH LLVM-exception, and extraction returns its leaf.
Deprecated identifiers (D01–D07, M11). The SPDX License List still lists GPL-2.0, GPL-2.0+, LGPL-2.1+, GPL-2.0-with-classpath-exception, wxWindows and GPL-3.0, marked deprecated. spdx in strict mode rejects every one (DeprecatedLicenseId). license-expression rewrites four of them to current identifiers (GPL-2.0 to GPL-2.0-only, GPL-2.0+ to GPL-2.0-or-later, likewise LGPL-2.1+ and GPL-3.0), keeps wxWindows, and rejects GPL-2.0-with-classpath-exception as a misplaced exception. In GPL-2.0-only WITH Nokia-Qt-exception-1.1 (a deprecated exception), both spdx-expression-parse versions and go-spdx reject it. license-expression rewrites it to Qt-LGPL-exception-1.1, a different exception. spdx and packaging keep it.
The + operator (S08, U01–U05). The grammar allows + after any license identifier. license-expression rejects MIT+, CDDL-1.0+ and Apache-1.1+ WITH LLVM-exception as unknown keys. spdx rejects GPL-2.0-or-later+ (GnuNoPlus), while go-spdx silently drops the +. go-spdx also rejects U05.
References and additions (S06–S07, I05–I07, R02–R05, W03–W05). license-expression treats every user-defined LicenseRef- as unknown in strict validation. spdx-tools resolves those symbols against the document itself. It also maps LicenseRef-Commercial to its own LicenseRef-scancode-commercial-license (R05), which changes the meaning. packaging accepts the invalid prefixes licenseref-foo and LICENSEREF-foo, normalising them to LicenseRef-foo, and rejects DocumentRef-…:LicenseRef-…. spdx accepts the empty LicenseRef-. Only spdx accepts the SPDX 3.0 form GPL-2.0-only WITH AdditionRef-x. LicenseRef-x WITH Classpath-exception-2.0 is valid (a license reference is a simple expression), but spdx-expression-parse 3.0.1, license-expression and go-spdx reject it.
Tokenisation (X14–X16). MIT ORApache-2.0 has no space after the operator, so the second token is not a license identifier. Both spdx-expression-parse versions and go-spdx read it as MIT OR Apache-2.0. A tab between terms splits the parsers 3–3. All six accept surrounding spaces and reject NONE, and only spdx accepts NOASSERTION.
5. Real-world sample
On 2026-11-16 we fetched the PEP 639 license_expression field for the 300 most-downloaded PyPI projects (hugovk/top-pypi-packages, 30-day list of 2026-11-01) and the license field of the latest version of the 300 most-downloaded npm packages (npm-high-impact 1.13.0). We used only unauthenticated public GETs. 153 PyPI projects set the field, and all 300 npm packages had a string. These 453 values contain only 23 distinct strings, dominated by MIT (310), Apache-2.0 (40), BSD-3-Clause (37) and ISC (20). The six parsers agreed on 22 of the 23. The exception is LGPL-2.1 (paramiko 5.1.0, a deprecated identifier): spdx rejected it, license-expression accepted it as LGPL-2.1-only, and the other four kept it. Popular packages stay inside the subset every parser accepts. The disagreements in §4 matter for less common packages and for strings that agents or users type by hand, which this sample does not measure.
6. Implications (hypotheses)
Hypothesis: a package whose metadata says apache-2.0 OR mit passes PyPI-side validation (packaging) but would fail a Node or Rust gate built on spdx-expression-parse or spdx. Hypothesis: an allow-list gate built on spdx-satisfies will error, rather than decide, on expressions that use lower-case operators, which Annex B allows. Hypothesis: SBOM pipelines that normalise with license-expression can change an exception (Nokia-Qt-exception-1.1 to Qt-LGPL-exception-1.1) or a user reference (LicenseRef-Commercial). A downstream policy then sees a license the author never wrote. Hypothesis: agents that emit canonical-case identifiers, upper-case operators, current (non-deprecated) identifiers and spaces around every operator avoid every disagreement we measured. We did not test any agent.
7. Threats to validity
- Synthetic cases. All 91 cases are ours. They show that behaviours differ, not how often each string occurs; the real-world sample shows the common strings are safe.
- Readings. Annex B is the reference. Some readings involve policy (deprecated identifiers are on the list but discouraged;
AdditionRef-is new in SPDX 3.0), and the raw outcomes inresults/do not depend on our classes. - API choice. We used each library’s documented validating entry point with defaults. Other modes exist (the
spdxcrate’s lax mode, license-expression withoutstrict, go-spdx options) and change some answers. - No tree for two subjects. packaging and go-spdx are compared on acceptance and leaf sets only. Their precedence is covered by the probes (go-spdx) or not at all (packaging).
- Versions and lists. One version per library and bundled license lists of different ages (3.27.0 to 3.29.0); a newly added identifier would split the parsers by list age.
8. Conclusion
Six SPDX expression parsers disagreed on whether to accept 34 of 91 expressions, while agreeing on every precedence case. The splits follow rules Annex B states explicitly: case-insensitive identifiers, all-upper or all-lower operators, deprecated identifiers that stay valid, + after any identifier, LicenseRef- and AdditionRef- forms, and whitespace around operators. Every implementation departs from at least one of these. Producers, including agents, should write canonical-case current identifiers with upper-case, space-separated operators. Consumers should not treat one parser’s verdict as the standard’s. The case set can serve as a regression suite.
Appendix A. Full case list and verdict matrix
“sep” is spdx-expression-parse. Cells: ✓ = class A (an accepted tree or leaf set equal to the reading, or a rejection of an invalid string); “R rej” = rejected a valid expression; “L acc” = accepted an invalid one; “N …” = accepted, with the identifier rewritten as shown; “T …” = accepted with a different meaning; “acc”/“rej” for open cases. Expected trees use (OP a b …) with same-operator chains flattened.
Unanimous cases (all six agree; the reading holds): S01 MIT; S02 Apache-2.0; S03 MIT OR Apache-2.0; S04 MIT AND Apache-2.0; S05 GPL-2.0-or-later WITH Classpath-exception-2.0; S09 (MIT OR Apache-2.0) AND BSD-3-Clause; S10 Apache-2.0 WITH LLVM-exception; P01 LGPL-2.1-only OR BSD-3-Clause AND MIT; P02 MIT AND BSD-3-Clause OR Apache-2.0; P03 MIT OR Apache-2.0 AND BSD-2-Clause OR ISC; P04 GPL-2.0-only WITH Classpath-exception-2.0 OR MIT; P05 MIT AND GPL-2.0-only WITH Classpath-exception-2.0; P06 (MIT); P07 ((MIT)); P08 MIT AND (Apache-2.0 OR BSD-3-Clause); P09 (MIT OR Apache-2.0) AND (BSD-2-Clause OR ISC); P10 MIT AND Apache-2.0 AND BSD-3-Clause OR ISC; I08 documentref-a:LicenseRef-b (all reject); D06 Nokia-Qt-exception-1.1 (all reject); D08 Foo-License-1.0 (all reject); D09 MIT OR Foo-License-1.0 (all reject); U03 MIT + (all reject); U04 LicenseRef-foo+ (all reject); W01 MIT WITH Apache-2.0 (all reject); W02 Classpath-exception-2.0 (all reject); W03 GPL-2.0-only WITH LicenseRef-x (all reject); W06 GPL-2.0-only WITH Classpath-exception-2.0 WITH LLVM-exception (all reject); W07 (MIT OR Apache-2.0) WITH LLVM-exception (all reject); W08 GPL-2.0-only WITH (all reject); W09 WITH Classpath-exception-2.0 (all reject); X01 (empty) (all reject); X02 MIT OR (all reject); X03 OR MIT (all reject); X04 MIT AND AND Apache-2.0 (all reject); X05 (MIT OR Apache-2.0 (all reject); X06 MIT OR Apache-2.0) (all reject); X07 () (all reject); X08 MIT/Apache-2.0 (all reject); X09 MIT, Apache-2.0 (all reject); X10 MIT Apache-2.0 (all reject); X11 MIT OR(Apache-2.0); X12 (MIT)OR(Apache-2.0); X13 MIT OR Apache-2.0; X14 MIT; R01 LicenseRef-my_license (all reject); R04 LicenseRef-scancode-unknown-license-reference; M01 Apache 2.0 (all reject); M02 MIT License (all reject); M03 BSD (all reject); M04 UNLICENSED (all reject); M05 SEE LICENSE IN LICENSE (all reject); M06 NONE (all reject); M08 MIT OR Apache-2.0; M09 Apache-2.0 WITH LLVM-exception OR MIT; M10 (MIT OR Apache-2.0) AND Unicode-3.0; M12 Python-2.0.
Disagreeing cases (and the two open cases on which the parsers split):
| # | Expression | Annex B reading | sep 5.0.0 | sep 3.0.1 | license-expression | spdx (Rust) | packaging | go-spdx |
|---|---|---|---|---|---|---|---|---|
| S06 | LicenseRef-Proprietary | LicenseRef-Proprietary | ✓ | ✓ | R rej | ✓ | ✓ | ✓ |
| S07 | DocumentRef-spdx-tool-1.2:LicenseRef-MIT-Style-2 | DocumentRef-spdx-tool-1.2:LicenseRef-MIT-Style-2 | ✓ | ✓ | R rej | ✓ | R rej | ✓ |
| S08 | CDDL-1.0+ | CDDL-1.0+ | ✓ | ✓ | R rej | ✓ | ✓ | ✓ |
| K01 | MIT or Apache-2.0 | (OR MIT Apache-2.0) | ✓ | R rej | ✓ | ✓ | ✓ | R rej |
| K02 | MIT and Apache-2.0 | (AND MIT Apache-2.0) | ✓ | R rej | ✓ | ✓ | ✓ | R rej |
| K03 | GPL-2.0-or-later with Classpath-exception-2.0 | GPL-2.0-or-later WITH Classpath-exception-2.0 | ✓ | R rej | ✓ | ✓ | ✓ | ✓ |
| K04 | MIT Or Apache-2.0 | invalid | L acc | ✓ rej | L acc | ✓ rej | L acc | ✓ rej |
| K05 | MIT aNd Apache-2.0 | invalid | L acc | ✓ rej | L acc | ✓ rej | L acc | ✓ rej |
| K06 | GPL-2.0-or-later With Classpath-exception-2.0 | invalid | L acc | ✓ rej | L acc | ✓ rej | L acc | L acc |
| K07 | MIT OR Apache-2.0 and BSD-3-Clause | (OR MIT (AND Apache-2.0 BSD-3-Clause)) | ✓ | R rej | ✓ | ✓ | ✓ | R rej |
| I01 | mit | MIT | R rej | R rej | ✓ | R rej | ✓ | ✓ |
| I02 | apache-2.0 OR mit | (OR Apache-2.0 MIT) | R rej | R rej | ✓ | R rej | ✓ | ✓ |
| I03 | Gpl-2.0-Or-Later WITH classpath-exception-2.0 | GPL-2.0-or-later WITH Classpath-exception-2.0 | R rej | R rej | ✓ | R rej | ✓ | ✓ |
| I04 | BSD-3-CLAUSE | BSD-3-Clause | R rej | R rej | ✓ | R rej | ✓ | ✓ |
| I05 | licenseref-foo | invalid | ✓ rej | ✓ rej | ✓ rej | ✓ rej | L acc | ✓ rej |
| I06 | LICENSEREF-foo | invalid | ✓ rej | ✓ rej | ✓ rej | ✓ rej | L acc | ✓ rej |
| I07 | LicenseRef-FOO | LicenseRef-FOO | ✓ | ✓ | R rej | ✓ | ✓ | ✓ |
| D01 | GPL-2.0 | GPL-2.0 | ✓ | ✓ | N GPL-2.0-only | R rej | ✓ | ✓ |
| D02 | GPL-2.0+ | GPL-2.0+ | ✓ | ✓ | N GPL-2.0-or-later | R rej | ✓ | ✓ |
| D03 | LGPL-2.1+ | LGPL-2.1+ | ✓ | ✓ | N LGPL-2.1-or-later | R rej | ✓ | ✓ |
| D04 | GPL-2.0-with-classpath-exception | GPL-2.0-with-classpath-exception | ✓ | ✓ | R rej | R rej | ✓ | ✓ |
| D05 | wxWindows | wxWindows | ✓ | ✓ | ✓ | R rej | ✓ | ✓ |
| D07 | GPL-2.0-only WITH Nokia-Qt-exception-1.1 | GPL-2.0-only WITH Nokia-Qt-exception-1.1 | R rej | R rej | N GPL-2.0-only WITH Qt-LGPL-exception-1.1 | ✓ | ✓ | R rej |
| U01 | MIT+ | MIT+ | ✓ | ✓ | R rej | ✓ | ✓ | ✓ |
| U02 | GPL-2.0-or-later+ | GPL-2.0-or-later+ | ✓ | ✓ | R rej | R rej | ✓ | N GPL-2.0-or-later |
| U05 | Apache-1.1+ WITH LLVM-exception | Apache-1.1+ WITH LLVM-exception | ✓ | ✓ | R rej | ✓ | ✓ | R rej |
| W04 | GPL-2.0-only WITH AdditionRef-x | GPL-2.0-only WITH AdditionRef-x | R rej | R rej | R rej | ✓ | R rej | R rej |
| W05 | LicenseRef-x WITH Classpath-exception-2.0 | LicenseRef-x WITH Classpath-exception-2.0 | ✓ | R rej | R rej | ✓ | ✓ | R rej |
| X15 | MIT\tOR Apache-2.0 | open | rej | rej | acc | acc | acc | rej |
| X16 | MIT ORApache-2.0 | invalid | L acc | L acc | ✓ rej | ✓ rej | ✓ rej | L acc |
| R02 | LicenseRef- | invalid | ✓ rej | ✓ rej | ✓ rej | L acc | ✓ rej | ✓ rej |
| R03 | LicenseRef-a.b-c | LicenseRef-a.b-c | ✓ | ✓ | R rej | ✓ | ✓ | ✓ |
| R05 | MIT AND LicenseRef-Commercial | (AND MIT LicenseRef-Commercial) | ✓ | ✓ | T (AND MIT LicenseRef-scancode-commercial-license) | ✓ | ✓ | ✓ |
| M07 | NOASSERTION | open | rej | rej | rej | acc | rej | rej |
| M11 | GPL-3.0 | GPL-3.0 | ✓ | ✓ | N GPL-3.0-only | R rej | ✓ | ✓ |
Allow-list probes (spdx-satisfies 6.0.1 / go-spdx Satisfies / spdx evaluate; expected per Annex B). P01 LGPL-2.1-only OR BSD-3-Clause AND MIT: {LGPL-2.1-only} yes, {BSD-3-Clause} no, {BSD-3-Clause, MIT} yes. P02 MIT AND BSD-3-Clause OR Apache-2.0: {Apache-2.0} yes, {MIT} no, {MIT, BSD-3-Clause} yes. P03 MIT OR Apache-2.0 AND BSD-2-Clause OR ISC: {ISC} yes, {Apache-2.0} no, {Apache-2.0, BSD-2-Clause} yes. P08 MIT AND (Apache-2.0 OR BSD-3-Clause): {MIT} no, {MIT, BSD-3-Clause} yes, {Apache-2.0} no. P10 MIT AND Apache-2.0 AND BSD-3-Clause OR ISC: {ISC} yes, {MIT, Apache-2.0} no, {MIT, Apache-2.0, BSD-3-Clause} yes. M09 Apache-2.0 WITH LLVM-exception OR MIT: {MIT} yes, {Apache-2.0} no. All three probers matched on all of these. K07 MIT OR Apache-2.0 and BSD-3-Clause: {MIT} yes, {Apache-2.0} no. spdx matched; spdx-satisfies and go-spdx raised errors.
References
- SPDX Specification 3.0.1, Annex B: SPDX License Expressions (Normative). https://spdx.github.io/spdx-spec/v3.0.1/annexes/spdx-license-expressions/
- SPDX License List and License Exceptions List (deprecated identifiers), spdx/license-list-data. https://github.com/spdx/license-list-data
- P. Ombredanne, C. A. M. Gerlach, K. Surma. PEP 639: Improving License Clarity with Better Package Metadata. 2024. https://peps.python.org/pep-0639/
- W. M. McKeeman. Differential Testing for Software. Digital Technical Journal 10(1), 1998.
- C. Wang, J. Wu, H. Lyu, X. Ling, T. Luo, Y. Wu, C. Zhao. A Large Scale Empirical Analysis on the Adherence Gap between Standards and Tools in SBOM. ACM TOSEM, 2026. https://doi.org/10.1145/3788692
- A. Prado, O. Zendra, P. Boinot, O. Barais. Mind the Gap: How SBOM Specification Ambiguities Lead to Divergent Software Bills of Materials. An Empirical Tool Study. arXiv:2609.19920, 2026.
- S. Xu, Y. Gao, L. Fan, Z. Liu, Y. Liu, H. Ji. LiDetector: License Incompatibility Detection for Open Source Software. ACM TOSEM 32(1), 2023 (online 2022). https://doi.org/10.1145/3518994
- jslicense/spdx-expression-parse.js, README (operator case). https://github.com/jslicense/spdx-expression-parse.js
- EmbarkStudios/spdx,
ParseModedocumentation. https://docs.rs/spdx/0.13.6/spdx/struct.ParseMode.html