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

Type inference in DMN context <result> row causes error message for decision tables with single output column #356

Open
hanjoosten opened this issue Jun 20, 2023 · 9 comments
Assignees
Labels
area:dmn Related to DMN area:engine Related to the runtime engines type:bug Something is behaving unexpectedly

Comments

@hanjoosten
Copy link

hanjoosten commented Jun 20, 2023

See this discussion at zulipchat.

in the DMNEvaluator compiler, https://github.com/kiegroup/drools/blob/053ca95475b0b51f2a9b8ee9f08a54b01d389140/kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/compiler/DMNEvaluatorCompiler.java#L819-L858
when a decision table of 1 output, is nested in the result context entry of a boxed context which is the body of a boxed function definition, it is not possible to infer the type and the compilation error is returned.
the reproducer shows a boxed function definition in a context entry of a boxed context, which is only partially relevant.
the function definition defines as body a boxed context, and a decision table of 1 output, as the body's boxed context final result entry, reproducing the compiler error.
it is likely reproducible also for a boxed function definition directly nested in a decision node (albeit not best practice either).

reproducer.zip

Acceptance criteria:

  • There is no error message with the use case.
  • Test reproducing the problem created along the fix.
@jomarko jomarko added type:bug Something is behaving unexpectedly area:dmn Related to DMN labels Jun 20, 2023
@jomarko jomarko changed the title Type inference causes error message Type inference in DMN context <result> row causes error message for decision tables with single output column Jun 20, 2023
@baldimir baldimir added the area:engine Related to the runtime engines label Jun 20, 2023
@baldimir baldimir moved this to Ready to take 🫵 (top to bottom) in IBM and KIE Community Project - Archived! Jun 20, 2023
@jomarko
Copy link

jomarko commented Jun 12, 2024

Probably only validation is affected by this issue. I was able to execute such model. See the attached screenshot.

Screenshot 2024-06-12 093349

However, I can confirm there is validation error for such model.
Screenshot 2024-06-12 093504

@gitgabrio
Copy link

Maybe related - somehow - with #956

@baldimir
Copy link

This may need to be retested. There were some big changes in the backend internals.

@ljmotta
Copy link

ljmotta commented Sep 3, 2024

@gitgabrio @baldimir I took a look into this issue, and we don't have the error anymore, but we still have a warning and info response from the JIT Executor. The output column of a nested Decision Table shouldn't have the same name as the parent cell? In this case "Test" as it's the Context Expression result? And I'm not sure about the DECISION_TABLE_ANALYSIS_EMPTY.

image

[
    {
        "severity": "WARN",
        "message": "Decision table with single output on node 'Test' should not have output name",
        "messageType": "ILLEGAL_USE_OF_NAME",
        "sourceId": "_F1544A23-3026-42D3-892F-1B31E5015E77",
        "path": "Untitled.dmn",
        "level": "WARNING"
    },
    {
        "severity": "INFO",
        "message": "Decision Table Analysis of table '[ID: _D6E81FEB-748D-4D56-ADAA-AC7F49ECF00D]' finished with no messages to be reported.",
        "messageType": "DECISION_TABLE_ANALYSIS_EMPTY",
        "sourceId": "_D6E81FEB-748D-4D56-ADAA-AC7F49ECF00D",
        "path": "Untitled.dmn",
        "level": "INFO"
    }
]

Here is my model:

"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<definitions xmlns=\"https://www.omg.org/spec/DMN/20230324/MODEL/\" expressionLanguage=\"https://www.omg.org/spec/DMN/20230324/FEEL/\" namespace=\"https://kie.org/dmn/_4D000131-E639-460F-B996-88331CA47A6F\" id=\"_15514F0E-9BDE-4624-B6A9-35700B01D028\" name=\"DMN_91FB6F98-CB1A-4441-B6B5-3CF0C30E61AF\" xmlns:dmndi=\"https://www.omg.org/spec/DMN/20230324/DMNDI/\" xmlns:dc=\"http://www.omg.org/spec/DMN/20180521/DC/\" xmlns:di=\"http://www.omg.org/spec/DMN/20180521/DI/\" xmlns:kie=\"https://kie.org/dmn/extensions/1.0\">\n  <decision name=\"Test\" id=\"_815A1579-9315-4D33-8487-1C17096CCA1F\">\n    <variable name=\"Test\" id=\"_DBA825F5-E8BC-40B5-A217-CEB5E0D87F63\" typeRef=\"string\" />\n    <context id=\"_B817F558-6A5E-4569-B9F4-61E3BCAA747A\" typeRef=\"string\" label=\"Test\">\n      <contextEntry id=\"_D79D26A9-10F5-43C8-B6D0-BB112F84006C\">\n        <variable id=\"_CB57EFDA-FAA8-4B89-8108-25E6E12B0598\" name=\"my variable\" typeRef=\"boolean\" />\n        <literalExpression id=\"_09FE31EE-475C-4E05-A72F-E20ABE629831\" typeRef=\"boolean\" label=\"my variable\">\n          <text>false</text>\n        </literalExpression>\n      </contextEntry>\n      <contextEntry id=\"_0295D981-61B8-4A8D-BC27-A8D805C10F46\">\n        <decisionTable id=\"_D6E81FEB-748D-4D56-ADAA-AC7F49ECF00D\" typeRef=\"string\" hitPolicy=\"UNIQUE\" label=\"Test\">\n          <input id=\"_B5C80D99-B558-48E5-B2ED-35E05D6A18AC\">\n            <inputExpression id=\"_F6BE08C2-4BB7-4270-8371-2F429BF3E522\" typeRef=\"boolean\">\n              <text>my variable</text>\n            </inputExpression>\n          </input>\n          <output id=\"_F1544A23-3026-42D3-892F-1B31E5015E77\" name=\"Output-1\" />\n          <annotation name=\"Annotations\" />\n          <rule id=\"_62D16F37-CE2F-4F4F-9FD7-6DEC3CD5695E\">\n            <inputEntry id=\"_56D9A376-EC13-4BF2-94C4-096A369343D3\">\n              <text>false</text>\n            </inputEntry>\n            <outputEntry id=\"_7152FDC9-EE89-4A70-89DF-D14C984FDB0B\">\n              <text>&quot;aaaa&quot;</text>\n            </outputEntry>\n            <annotationEntry>\n              <text>// Your annotations here</text>\n            </annotationEntry>\n          </rule>\n          <rule id=\"_1D26E836-A943-4C4C-BC3B-D3847F135135\">\n            <inputEntry id=\"_B850454F-85BA-4C72-85C4-97D43B9DCF68\">\n              <text>true</text>\n            </inputEntry>\n            <outputEntry id=\"_FC43F5D6-5E92-4F27-80B1-E2195F37F35D\">\n              <text>&quot;bbbb&quot;</text>\n            </outputEntry>\n            <annotationEntry>\n              <text></text>\n            </annotationEntry>\n          </rule>\n        </decisionTable>\n      </contextEntry>\n    </context>\n  </decision>\n  <dmndi:DMNDI>\n    <dmndi:DMNDiagram id=\"_DC68F5AC-F362-4AA2-93A3-A7802FB033EB\" name=\"Default DRD\" useAlternativeInputDataShape=\"false\">\n      <di:extension>\n        <kie:ComponentsWidthsExtension>\n          <kie:ComponentWidths dmnElementRef=\"_B817F558-6A5E-4569-B9F4-61E3BCAA747A\">\n            <kie:width>120</kie:width>\n          </kie:ComponentWidths>\n          <kie:ComponentWidths dmnElementRef=\"_09FE31EE-475C-4E05-A72F-E20ABE629831\">\n            <kie:width>190</kie:width>\n          </kie:ComponentWidths>\n          <kie:ComponentWidths dmnElementRef=\"_D6E81FEB-748D-4D56-ADAA-AC7F49ECF00D\">\n            <kie:width>60</kie:width>\n            <kie:width>118</kie:width>\n            <kie:width>118</kie:width>\n            <kie:width>240</kie:width>\n          </kie:ComponentWidths>\n        </kie:ComponentsWidthsExtension>\n      </di:extension>\n      <dmndi:DMNShape id=\"_4ED4E9BD-4A3E-4B24-926E-139ED6F3DEDA\" dmnElementRef=\"_815A1579-9315-4D33-8487-1C17096CCA1F\" isCollapsed=\"false\" isListedInputData=\"false\">\n        <dc:Bounds x=\"360\" y=\"0\" width=\"160\" height=\"80\" />\n      </dmndi:DMNShape>\n    </dmndi:DMNDiagram>\n  </dmndi:DMNDI>\n</definitions>\n"

@gitgabrio
Copy link

@ljmotta I'll take a look and report back

@gitgabrio
Copy link

gitgabrio commented Sep 4, 2024

@ljmotta @baldimir @yesamer
About ILLEGAL_USE_OF_NAME message

From the specs

8 Decision Table
8.1 Introduction
...
A set of outputs (one or more). A single output has no name, only a value.

So, the model you provided is actually invalid. In the current version of jitexecutor, we set the validation mode to strict, so that model validation should fail. I think the sandbox is still using the old, "permissive" version.

@gitgabrio
Copy link

gitgabrio commented Sep 4, 2024

@ljmotta @baldimir @yesamer
About DECISION_TABLE_ANALYSIS_EMPTY message,
currently jitexecutor returns all messages from validation. We have to decide if jitexecutor should filter some of them (i.e. exclude "info" ones), or if the filtering should be done on frontend side

@ljmotta
Copy link

ljmotta commented Sep 4, 2024

@gitgabrio Thanks for the pointers. I've created #1466 for the validation ILEGAL_USE_OF_NAME.

Regarding the DECISION_TABLE_ANALYSIS_EMPTY message, I'm not sure about the usage of it. I mean, the evaluation was a success? All INFO messages are like this one?

@gitgabrio
Copy link

@ljmotta
INFO messages are just information, the validation is successful, and they could be simply discarded/ignored.
That's why I wrote that we just have to decide who does the discards (jitexecutor vs frontend): your call 😄
@baldimir @yesamer pls correct me if I'm wrong

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:dmn Related to DMN area:engine Related to the runtime engines type:bug Something is behaving unexpectedly
Projects
Status: 📋 Backlog
Development

No branches or pull requests

5 participants