camunda/feel-scala

Regression regarding "satisfies" expression in combination with "in"

Closed this issue · 1 comments

Hi,

I am trying to find out what causes a bug in the Camunda DMN engine (camunda/camunda-bpm-platform#4075) and was able to narrow it down to a changed behaviour in the FEEL engine from 1.16.0 to 1.16.1. I do apologize for the code, but I am neither familiar with the FEEL engine API nor with scala, so I had to write it in Java with some workarounds.

Describe the bug

I try to evaluate the expression

every k in ? satisfies k.B in ["42"]

with the input

{
  "cellInput":[
    {
      "B": "42"
    }, 
    {
      "B": "42"
    }
  ]
}

so I would expect the expression to be evaluated to "true". This is confirmed by the FEEL playground.

To Reproduce

Please take a look at the following code.

public static void main( String[] args ) {
	var feelEngine = new FeelEngine.Builder( )
			.valueMapper( new ValueMapper.CompositeValueMapper( toScalaList( new JavaValueMapper( ) ) ) )
			.enableExternalFunctions( false )
			.build( );

	var expression = "every k in ? satisfies k.B in [\"42\"]";

	var variables = Map.of( "cellInput", List.of( Map.of( "B", "42" ), Map.of( "B", "42" ) ) );

	var context = new CustomContext( ) {
		public VariableProvider variableProvider( ) {
			return new VariableProvider( ) {

				@Override
				public Option getVariable( final String name ) {
					if ( variables.containsKey( name ) ) {
						return new Some<>( variables.get( name ) );
					} else {
						return None$.MODULE$;
					}
				}

				@Override
				public Iterable<String> keys( ) {
					return SetHasAsScala( variables.keySet( ) ).asScala( );
				}

			};
		}
	};

	var either = feelEngine.evalExpression( expression, context );
	System.out.println( either );
}

private static <T> camundajar.impl.scala.collection.immutable.List<T> toScalaList( T... elements ) {
	java.util.List<T> listAsJava = Arrays.asList( elements );
	return ListHasAsScala( listAsJava ).asScala( ).toList( );
}

Up to 1.16.0 this is evaluated correctly to "true", but since 1.16.1 it is evaluated to "false".

Expected behavior

The expression should be evaluated to "true".

Environment

@nils-christian thank you for reporting. The detailed information helped to reproduce the issue quickly. 👍

I verified the behavior with the latest patch versions 1.17.5 and 1.16.3. I can't reproduce the issue anymore. It seems to be fixed with #786. 🚀


Since I can't reproduce the issue anymore, I'm closing the issue. Please reopen it if the issue still occurs. ✔️