Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert regular exceptions into ExpressionError #97

Open
stefan6419846 opened this issue Jul 3, 2024 · 0 comments
Open

Convert regular exceptions into ExpressionError #97

stefan6419846 opened this issue Jul 3, 2024 · 0 comments

Comments

@stefan6419846
Copy link

I currently try to run validation of SPDX expression from arbitrary inputs. If something is wrong with the expression, I would have expected it to always populate the errors attribute instead of raising exceptions. Apparently, this is not the case in every situation.

Let's consider the following snippet:

from license_expression import get_spdx_licensing

licensing = get_spdx_licensing()
expression = '(Apache-2.0) AND ()'
result = licensing.validate(expression)
print(result.errors)

This fails with an IndexError during validation:

[...]
  File "/home/user/lib/python3.9/site-packages/license_expression/__init__.py", line 778, in validate
    parsed_expression = self.parse(expression, strict=strict)
  File "/home/user/lib/python3.9/site-packages/license_expression/__init__.py", line 545, in parse
    expression = super(Licensing, self).parse(tokens)
  File "/home/user/lib/python3.9/site-packages/boolean/boolean.py", line 316, in parse
    ast[0].append(ast[2])
IndexError: list index out of range
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

No branches or pull requests

1 participant