DMN evaluate error about missing context variables

Hi, everyone!

I just test dmn-evaluation with non-exist variable, see below:

If i don’t put ‘season’ variable to my Variable-Context, and then dmn-engin will thrown a error as like this: FEEL/SCALA-01008 Error while evaluating expression: failed to evaluate expression ‘season’: no variable found for name ‘season’. I use test code as:

@Test
  public void shouldServeDryAgedInSpringForFewGuests() {
    VariableMap variables = Variables
      // .putValue("season", "Spring")
      .putValue("guestCount", 5);

    DmnDecisionTableResult result = dmnEngine.evaluateDecisionTable(decision, variables);
    assertEquals("Dry Aged Gourmet Steak", result.getSingleResult().getSingleEntry());
  }

Some times the context-variables is missing key, this is normal behavior in my situation. Example i have a service-task to fetch some metrics and then set context, but when error occur, the all metrics must be null, i hope the process will go on, and how to promise that?

Hello @Lienider ,

when facing this issue, I would ask myself whether missing data is valid for the process.

So, if it is legal, you should be able to handle null values.

If not, you should test this after fetching data and let the task fail.

I hope this helps

Jonathan

I see what you’re saying, maybe I can do for now is to assign a NULL to all the context-variables to be DMN evaluation.

Thanks Reply!

Thinking of FeelEngine’s FunctionProvider extension about NULL value handle if anything else needed,

Raw support is like this:

or this

Also can use other script impl, e.g. juel, js and so on…

1 Like