Skip to content

"Complex" unary tests with "true" expressions ignore input value #954

@par-shd

Description

@par-shd

Describe the bug
While using the FEEL engine, I encountered situations where the unary tests keep returning "true", while they shouldn't. Let's consider the following 3 cases as valid responses:

  1. Expression: true
    Input: false
    // Result: false
    https://camunda.github.io/feel-scala/docs/playground/?expression-type=unary-tests&expression=dHJ1ZQ%3D%3D&context=e30%3D&input-value=ZmFsc2U%3D

  2. Expression: true
    Input: null
    // Result: false
    https://camunda.github.io/feel-scala/docs/playground/?expression-type=unary-tests&expression=dHJ1ZQ%3D%3D&context=e30%3D&input-value=bnVsbA%3D%3D

  3. Expression: true
    Input: "hello"
    // Result: null with a warning [NOT_COMPARABLE]
    https://camunda.github.io/feel-scala/docs/playground/?expression-type=unary-tests&expression=dHJ1ZQ%3D%3D&context=e30%3D&input-value=ImhlbGxvIg%3D%3D

To Reproduce
Now if I make the expression a bit "complex", I'll get unexpected results. Consider the same tests, but this time with the expression: 3 > 1

  1. Expression: 3 > 1
    Input: false
    // Result: true
    // Expected: false
    https://camunda.github.io/feel-scala/docs/playground/?expression-type=unary-tests&expression=MyA%2BIDE%3D&context=e30%3D&input-value=ZmFsc2U%3D

  2. Expression: 3 > 1
    Input: null
    // Result: true
    // Expected: false
    https://camunda.github.io/feel-scala/docs/playground/?expression-type=unary-tests&expression=MyA%2BIDE%3D&context=e30%3D&input-value=bnVsbA%3D%3D

  3. Expression: 3 > 1
    Input: "hello"
    // Result: true
    // Expected: null with a warning [NOT_COMPARABLE]
    https://camunda.github.io/feel-scala/docs/playground/?expression-type=unary-tests&expression=MyA%2BIDE%3D&context=e30%3D&input-value=ImhlbGxvIg%3D%3D

You can test the same cases, but with different expressions. The following expressions also lead to the same problem (and probably more cases):

  • all([true])
  • any([true])
  • contains("foobar", "foo")

Expected behavior
The expression must be compared with the input. It shouldn't be always "true"

Environment

  • FEEL engine version: [1.18.1]

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