Skip to content

Fix validate() to report errors for invalid SPDX expressions with tra…#126

Merged
AyanSinhaMahapatra merged 2 commits into
aboutcode-org:mainfrom
saquibsaifee:fix/validate-trailing-operators
May 15, 2026
Merged

Fix validate() to report errors for invalid SPDX expressions with tra…#126
AyanSinhaMahapatra merged 2 commits into
aboutcode-org:mainfrom
saquibsaifee:fix/validate-trailing-operators

Conversation

@saquibsaifee
Copy link
Copy Markdown
Contributor

Description

The validate() method failed silently when encountering expressions with trailing operators (e.g. 'GPL-3.0-or-later AND'). The root cause was that the exception handler accessed e.token_string on ExpressionError, but only ExpressionParseError (a subclass) has that attribute.

Fix by catching ExpressionParseError and ExpressionError separately.

Fixes #114

…iling operators

The validate() method failed silently when encountering expressions with
trailing operators (e.g. 'GPL-3.0-or-later AND'). The root cause was that
the exception handler accessed e.token_string on ExpressionError, but only
ExpressionParseError (a subclass) has that attribute.

Fix by catching ExpressionParseError and ExpressionError separately.

Fixes aboutcode-org#114

Signed-off-by: Saquib Saifee <saquibsaifee2@gmail.com>
@saquibsaifee
Copy link
Copy Markdown
Contributor Author

Take a look at this @AyanSinhaMahapatra @pombredanne.

@AyanSinhaMahapatra
Copy link
Copy Markdown
Member

Closing this as #127 was merged instead.
Thanks for the contribution @saquibsaifee

Copy link
Copy Markdown
Member

@AyanSinhaMahapatra AyanSinhaMahapatra left a comment

Choose a reason for hiding this comment

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

Thanks @saquibsaifee, I'm actually keeping this, the tests are useful enough.

@AyanSinhaMahapatra AyanSinhaMahapatra merged commit 2efada2 into aboutcode-org:main May 15, 2026
12 checks passed
@saquibsaifee saquibsaifee deleted the fix/validate-trailing-operators branch May 15, 2026 12:19
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.

validate() fails to report errors for invalid SPDX expressions

2 participants