Skip to content

validate() fails to report errors for invalid SPDX expressions #114

Description

@saquibsaifee

Problem

licensing.validate() method does not report errors for syntactically invalid SPDX license expressions that end with a trailing operator (e.g., AND or OR). According to the [SPDX License Expression Specification](https://spdx.github.io/spdx-spec/v3.0.1/annexes/spdx-license-expressions/), such expressions are invalid.

Steps to Reproduce

  1. from license_expression import get_spdx_licensing
    licensing = get_spdx_licensing()
    expression = "GPL-3.0-or-later AND GPL-2.0-or-later AND GPL-2.0-only AND"
    result = licensing.validate(expression)
    print(result)

Expected Behavior

The licensing.validate() method should report an error because the expression GPL-3.0-or-later AND GPL-2.0-or-later AND GPL-2.0-only AND is syntactically invalid due to the trailing AND.

Actual Behavior

The method returns ExpressionInfo with errors=[] and invalid_symbols=[], indicating no issues, even though the expression is malformed:

ExpressionInfo(
    original_expression='GPL-3.0-or-later AND GPL-2.0-or-later AND GPL-2.0-only AND',
    normalized_expression='GPL-3.0-or-later AND GPL-2.0-or-later AND GPL-2.0-only',
    errors=[],
    invalid_symbols=[]
)

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions