camunda / feel-scala

FEEL parser and interpreter written in Scala
https://camunda.github.io/feel-scala/
Apache License 2.0
119 stars 46 forks source link

The `context()` function doesn't work for a list with a value with a custom context #856

Closed saig0 closed 1 month ago

saig0 commented 1 month ago

Describe the bug The context() function doesn't work for a list value that contains a custom context. This is the case when the function is invoked in Camunda 8 with a process variable as the argument. See the details in the issue: https://github.com/camunda/camunda/issues/12740.

The function works fine if it is invoked with a list literal.

To Reproduce Steps to reproduce the behavior:

  1. Add the following test to BuiltinContextFunctionsTest and run it
  2. Verify that the test fails with the message: the evaluation didn't returned 'Map(a -> 1)' but 'null'
ScalaTest
it should "return a context with entries from a custom context" in {

    evaluateExpression(
      expression = """context(list)""",
      variables = Map(
        "list" -> List(
          ValContext(
            new MyCustomContext(
              Map(
                "key"   -> "a",
                "value" -> 1
              )
            )
          )
        )
      )
    ) should returnResult(Map("a" -> 1))
  }

Expected behavior I can invoke the context() function with a list that a custom context.

Environment