dmn abs function throws an error

33 views
Skip to first unread message

Ravi Mangalagiri

unread,
May 30, 2022, 3:55:57 PM5/30/22
to Kogito development mailing list
Hi Kogito Team,
I have a dmn and also defined a DMN Decision Service called evaluate.
I now imported the above dmn in another dmn and calling the decision service and passing the inputs
dmn1.evaluate(input, amountFromDMN2)
I double confirmed that both the inputs are not null.

The first dmn has a decision which uses the function abs(). and it throws an exception as follows.

The parameter 'duration', in function abs(), cannot be null.

I also tested the first dmn independently and it works just fine. All I have in the decision is abs(input.amount - amountFromDMN2)


The question is when does this error occur?

--
Ravi Mangalagiri

Ravi Mangalagiri

unread,
May 30, 2022, 4:37:25 PM5/30/22
to Kogito development mailing list
I was able to reproduce the error. Please find the attached 2 dmn(s)

payload 
{
    "loan": {
        "insuranceAmount": 5000
    }
}


also noticed the following exception in the console
executed 'loan.dmn' with 2 errors
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class org.kie.dmn.core.impl.DMNMetadataImpl and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: org.kie.dmn.core.impl.DMNContextImpl["metadata"])
loanCalc.dmn
loan.dmn

Matteo Mortari

unread,
May 31, 2022, 3:57:31 AM5/31/22
to Kogito development mailing list
Hi Ravi,
your Decision Service "evaluate" in the loanCalc.dmn defines the input parameters as: baseLoanAmount, loan (screenshot attached)

in your invoking loan.dmn model, you are invoking it by having inverted parameters: calc.evaluate(loan, baseLoanAmount) 
(screenshot attached)

If you are invoking positionally, you shall respect the correct order of the Invocable element (the Decision Service, in this case) parameters.

If you respect the correct positional ordering of the parameters during the inline invocation, no error is produced for the example payload reported.

Hope this helps!
MM


--
You received this message because you are subscribed to the Google Groups "Kogito development mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kogito-developm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kogito-development/2bbe2f26-8244-4318-ba4c-8f8c8478edbdn%40googlegroups.com.


--
Screenshot 2022-05-31 at 09.53.57.png
Screenshot 2022-05-31 at 09.50.40.png

Ravi Mangalagiri

unread,
May 31, 2022, 4:12:46 PM5/31/22
to Kogito development mailing list
Matteo,
The error is misleading ... and where is this documented? Not sure how I missed it.
Thanks. That fixed it



--
Ravi Mangalagiri

Matteo Mortari

unread,
Jun 1, 2022, 6:03:38 AM6/1/22
to Kogito development mailing list
Hi Ravi,

for the Documentation of the DMN Editor, I will let my colleagues for Tooling advise.
for the Documentation of the built-in functions, we are experimenting to provide a specialized handbook, for instance https://kiegroup.github.io/dmn-feel-handbook/#abs-n
in this case, it's trying to tell you that you have passed a null value to the abs() function as you know it's the result of the expression input.amount - amountFromDMN2
(it likely tried to use number variant first, then duration variants, but still null, hence it's reporting assuming duration).

How that occurred, it's a side effect of what I've described in my previous email.

For an analogy, if you invoke:
isParent( child, johnDoe )
or
isParent( johnDoe, child )
Which one is "the correct" one?
Hard to tell even for humans, it depends on the definition of the function.

For Invocable elements (a Decision Service, in this case) you may opt for a boxed invocation, as that corresponds to named-parameter-invocations, it would avoid this problem altogether.

Even though I personally use inline (positional) invocation a lot of the time, but that need to ensure the positional parameter is indeed the expected one.

Hope this clarifies further.
MM

Jozef Marko

unread,
Jun 1, 2022, 6:56:06 AM6/1/22
to kogito-de...@googlegroups.com
Regarding UI, there was an initiative of adding some functions documentation directly into editor UI, similar as we have for keyboard shortcuts for DMN or BPMN editor.

However this initiative was stopped due to a changed focus of the team. So there is no detailed documentation directly in editor/tooling of FEEL functions.

In other words, there are no example how to use 'abs' or similar. The autocompletion (should appear automatically when typing dmn literal expresison) just offers list of available functions.

Matteo Mortari

unread,
Jun 1, 2022, 7:53:04 AM6/1/22
to Kogito development mailing list
Just for completeness, specifically about

On Wed, 1 Jun 2022 at 12:56, Jozef Marko <jom...@redhat.com> wrote:
<snip>

In other words, there are no example how to use 'abs' or similar. 

that could be indeed a great situation where to make use of  https://kiegroup.github.io/dmn-feel-handbook/#abs-n

All the examples in there are verified against the latest Drools DMN engine (which includes FEEL engine).

Hope this helps,
MM
 
Reply all
Reply to author
Forward
0 new messages