Skip to content

Unary tests: sum(?) < 112 returns false, but sum(list: ?) < 112 is true (1.19.3) #1056

@kon-drees

Description

@kon-drees

Describe the bug

When evaluating a unary test that uses the built-in sum function with ? as the input (sum(?) < 112), the result is false, although the same condition expressed with a named parameter (sum(list: ?) < 112) or as a normal expression is true.

So:
sum(?) < 112 → unary tests: false
sum(list: ?) < 112 → unary tests: true
count(?) < 112 → unary tests: true

According to the FEEL semantics, unary tests should allow arbitrary expressions with ? as the input value, and sum(?) should behave the same as sum(list: ?) when the input is a list.

Environment
feel-engine: 1.19.3
Language: Java (Spring Boot service)
API used: FeelEngineApi#evaluateUnaryTests

Suspected root cause

sum is declared as a varargs built-in function. The varargs handling is done in FeelInterpreter.invokeFunction, where positional parameters are repacked into a ValList for functions with hasVarArgs = true.

In unary tests, the ? handling goes through UnaryTestExpression and getImplicitInputValue. With sum(list: ?) (named parameter) everything works, but with sum(?) (positional vararg) the unary test result for sum(?) < 112 ends up being false, even though sum(list: ?) < 112 and the corresponding normal expression are true.
count is not declared as varargs and works fine with count(?).
This suggests an inconsistency/bug in how varargs built-ins are invoked in the context of unary tests with positional parameters.

Expected behavior
evaluateUnaryTests("sum(?) < 112", List.of(1, 2, 3), …) should return true, just like:
evaluateUnaryTests("sum(list: ?) < 112", List.of(1, 2, 3), …) and
evaluateExpression("sum(input) < 112", Map.of("input", List.of(1, 2, 3))).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions