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

Investigate feel-scala 1.17.5 compatibility with camunda-bpm-platform #4100

Closed
3 tasks done
psavidis opened this issue Feb 13, 2024 · 6 comments
Closed
3 tasks done
Assignees
Labels
type:task Issues that are a change to the project that is neither a feature nor a bug fix. version:7.21.0-alpha4 version:7.21.0

Comments

@psavidis
Copy link
Contributor

psavidis commented Feb 13, 2024

Environment (Required on creation)

Camunda 7.21

Description (Required on creation; please attach any relevant screenshots, stacktraces, log files, etc. to the ticket)

The test CustomFunctionTest#shouldThrowExceptionDueToDisabledVarargs fails when the repository tries to be upgraded to use feel-scala:1.17.5.

Steps to reproduce (Required on creation)

  • Checkout the master on camunda 7.21.
  • Go to the pom.xml of camunda-root and Upgrade the version.feel-scala from 1.6.2 to 1.17.5
  • Build the project
  • Execute the test CustomFunctionTest#shouldThrowExceptionDueToDisabledVarargs

Observed Behavior (Required on creation)

The test CustomFunctionTest#shouldThrowExceptionDueToDisabledVarargs passes with feel-scala:1.6.2 and fails when the artifact is upgraded to 1.17.5

Expected behavior (Required on creation)

  • The test should pass
  • Any other test failure attributed to the feel-scala:1.17.5 should be fixed and the tests should pass.

Root Cause (Required on prioritization)

  • When a function is not found in an expression, instead of throwing an exception, feel-scala:1.7.x returns null.

Function registry

The feel engine has a FunctionProvider that will register a function its to internal registry.
During evaluation, that registry will be used to check if the function found in the expression the user passed exists.

Enable Varargs Evaluation

The enableVarargs directive or its absence indicate to the engine what parameters to expect during evaluation of the function name

e.g if a function is allowed to be called with variable arguments or not and calls like function(a), function(a,b...) are permitted (or not).

The Test Case

  • The test implicitly disables varargs, myFunction can only accept a list.

  • The arguments passed are variable arguments

  • As a result, the registered function is different from the one passed with varargs. From feel-engine's perspective, the function does not exist.

  • The test expects a FeelException to be thrown. The evaluation though returns null

    • There is a breaking change in feel-scala 1.7.0; The invocation of a non-existing function will return null.

Solution Ideas

Adapt the test to expect null instead when upgrading to feel-scala:1.7.15

Hints

Links

Breakdown

camunda-bpm-platform PR

Preview Give feedback
  1. ci:default-build
    psavidis

camunda-docs-manual PR

Preview Give feedback
  1. psavidis
  2. psavidis

Dev2QA handover

  • Does this ticket need a QA test and the testing goals are not clear from the description? Add a Dev2QA handover comment
@psavidis psavidis added the type:task Issues that are a change to the project that is neither a feature nor a bug fix. label Feb 13, 2024
@psavidis psavidis self-assigned this Feb 13, 2024
psavidis added a commit that referenced this issue Feb 14, 2024
Notable point of this change:

Changes in feel-scala:
- 1.6.2 legacy behaviour: when disabling the var-args evaluation and a given function with arguments that do not exist throws an Exception
- 1.7.5 new behaviour: The above returns successfully and the answer contains suppressed failures.
- FeelEngine#evalExpression are deprecated and changed to the new FeelEngineApi#evaluateExpression. They also contain breaking changes in behaviour.

Change Reason:
- Adapt the behaviour of ScalaFeelEngine appropriately so that the legacy behaviour of `ScalaFeelEngine` is retained.

Breaking change:
- FeelExceptions with "no function found" messages now start with a capital letter.
- This is accepted as a small change to make the proxy code as simple as possible

Related-to: #4100
@psavidis
Copy link
Contributor Author

psavidis commented Feb 15, 2024

Update

  • The CustomFunctionTest.shouldThrowExceptionDueToDisabledVararg is fixed by adjusting the test to expect null responses instead of throwing a FeelException.

There are further test failures that need to be investigated.

Postponing the progress of this item to move forward with other 7.21 items of higher priority.

@psavidis
Copy link
Contributor Author

psavidis commented Feb 26, 2024

Investigation of Other Failures

  • FeelBehavior#shouldFailOnInternalContextFunctions

    • Context: The test using feel-scala:1.16.2 throws the following exception: org.camunda.bpm.dmn.feel.impl.juel.FeelMissingFunctionException: FEEL-01007 Unable to resolve function 'dateTime' in expression 'not(dateTime())'
    • Cause: The dateTime function is an internal context function and should not be called. The test tries to use it and the function cannot be found. The response is an exception with missing function in feel-scala:1.6.2
    • Problem: The test fails in feel-scala:1.17.x cause the function returns null instead of throwing an exception
    • Links: ref
    • Solution:
      • The DMN rule should return a tuple containing [null, foo] due to the unique policy of the given associated dmn file.
      • Due to the expectation diverging from JuelFeelBehaviorTest, clone the test from the parent class FeelBehavior to the concrete JuelFeelBehaviorTest & ScalaFeelBehaviorTest and apply the changes only to the ScalaFeelBehaviorTest
  • BreakingScalaFeelBehaviorTest#shouldEvaluateTimezoneComparisonWithTypedValue

    • Context: The test using feel-scala:1.16.2 throws the following exception: org.camunda.bpm.dmn.feel.impl.FeelException: FEEL/SCALA-01008 Error while evaluating expression: failed to evaluate expression '<= date and time("2019-09-12T13:00:00@Europe/Berlin")': ValLocalDateTime(2024-02-27T11:01:27.850) can not be compared to ValDateTime(2019-09-12T13:00+02:00[Europe/Berlin])
    • Cause: The following expression should fail during evaluation due to different types being compared:
      • <= date and time("2019-09-12T13:00:00@Europe/Berlin")
    • Problem: The test fails in feel-scala:1.17.x cause the function returns false instead of throwing an exception.
    • Links:
    • Solution: Change the test to expect an empty DmnDecisionTableResult
  • BreakingScalaFeelBehaviorTest#shouldEvaluateTimezoneComparisonWithDate

    • Same as the above case
  • BreakingScalaFeelBehaviorTest#shouldUseSingleQuotesInStringLiterals

    • Context: The test using feel-scala:1.16.2 throws the following exception: org.camunda.bpm.dmn.feel.impl.FeelException: FEEL/SCALA-01008 Error while evaluating expression: failed to parse expression ''Hello World'': Expected (negation | positiveUnaryTests | anyInput):1:1, found \"'Hello Wor\"
    • Cause:
      • Unidentified why the juel expression 'Hello World' expression fails with the message "`Hello Wor"
      • The observation looks as if the closing literal ld' is parsed differently as a reserved word. Couldn't find it under JUEL Reserved Words section
    • Problem: The test fails in feel-scala:1.17.x with an enriched exception message: FEEL/SCALA-01008 Error while evaluating expression: failed to parse expression ''Hello World'': Expected (start-of-input | negation | positiveUnaryTests | anyInput):1:1, found "'Hello Wor".
    • Solution: Change the expected message reason from negation to start-of-input | negation

psavidis added a commit that referenced this issue Feb 26, 2024
Description:
- In feel-scala:1.6.2, the evaluation of an internal context function would throw a FeelMissingFunctionException
- In feel-scala:1.7.4, the evaluation will return null instead since dateTime is a context function and should not be resolved. This call will return null.
- The change adapts the test for feel-scala to make this consideration

Related-to: #4100
psavidis added a commit that referenced this issue Feb 26, 2024
Description:
- In feel-scala:1.6.2, the evaluation of an internal context function would throw a FeelMissingFunctionException
- In feel-scala:1.7.4, the evaluation will return null instead since dateTime is a context function and should not be resolved. This call will return null.
- The change adapts the test for feel-scala to make this consideration

Related-to: #4100
psavidis added a commit to camunda/camunda-docs-manual that referenced this issue Feb 28, 2024
- Add documentation to the migration guide for the upgrade of feel-engine to 1.7.x version
- List identified breaking changes and full release notes change log

Related-to: camunda/camunda-bpm-platform#4100
@psavidis psavidis assigned tasso94 and unassigned psavidis Feb 29, 2024
@psavidis
Copy link
Contributor Author

Next Step

👀 The CI passed with the adapted tests. Assigning the ticket to @tasso94 for review.

@tasso94 tasso94 assigned psavidis and unassigned tasso94 Mar 6, 2024
@psavidis psavidis assigned tasso94 and unassigned psavidis Mar 6, 2024
@psavidis
Copy link
Contributor Author

psavidis commented Mar 6, 2024

Update

Incorporated the Code review points and changed the description to reflect accurately the new behaviour of the FEEL engine on comparing different datatypes.

After the final approval on the documentation, the PRs can be merged.

@tasso94 tasso94 assigned psavidis and unassigned tasso94 Mar 7, 2024
psavidis added a commit that referenced this issue Mar 7, 2024
Why: Breaking changes of feel-scala 1.7.5
Context: Feel-Scala Breaking Changes Fixed in this commit
    - After feel-scala:1.7.0, Not found functions return null instead of throwing a `FeelMissingFunctionException` (e.g `date` internal context function)
    - Comparing different types is handled gracefully instead of throwing an exception by returning `false` or `null`
    - Adjustments in the exception message
Links: #4100 (comment)
Related-to: #4100
psavidis added a commit to camunda/camunda-docs-manual that referenced this issue Mar 7, 2024
Context: Add description in the migration guide of the the support and breaking changes of FEEL engine 1.7.0
Co-authored-by: tasso94
Co-authored-by: petros.savvidis
Related-to: camunda/camunda-bpm-platform#4100
@psavidis
Copy link
Contributor Author

psavidis commented Mar 7, 2024

Update

PRs have been merged to master. Closing the ticket.

@psavidis
Copy link
Contributor Author

Update

The version in the docs was not correct (1.7 instead of 1.17). Opened a PR to correct it; kudos to @yanavasileva for noticing that 👍

psavidis added a commit to camunda/camunda-docs-manual that referenced this issue Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:task Issues that are a change to the project that is neither a feature nor a bug fix. version:7.21.0-alpha4 version:7.21.0
Projects
None yet
Development

No branches or pull requests

3 participants