-
Notifications
You must be signed in to change notification settings - Fork 52
Description
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:
-
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 -
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 -
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
-
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 -
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 -
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]