Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
nils-christian opened this issue Feb 9, 2024 · 1 comment
Closed

Comments

@nils-christian
Copy link

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

@saig0
Copy link
Member

saig0 commented Feb 12, 2024

@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. ✔️

@saig0 saig0 closed this as completed Feb 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants