Re: [PR] [incubator-kie-issues#2015] Add error handling modes in DMN engine [incubator-kie-drools]

2026-02-10 Thread via GitHub


Copilot commented on code in PR #6387:
URL: 
https://github.com/apache/incubator-kie-drools/pull/6387#discussion_r2789056234


##
kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/compiler/RuntimeModeOption.java:
##
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.kie.dmn.core.compiler;
+
+import java.io.Serial;
+import org.kie.dmn.core.assembler.DMNAssemblerService;
+
+public class RuntimeModeOption implements DMNOption {
+
+public static final String PROPERTY_NAME = 
DMNAssemblerService.ORG_KIE_DMN_PREFIX + ".runtime.mode";
+
+@Serial
+private static final long serialVersionUID = -372562279892008329L;
+
+public enum MODE {
+LENIENT("lenient"),
+STRICT("strict");
+
+private final String mode;
+
+MODE(String mode) {
+this.mode = mode;
+}
+
+public String getMode() {
+return mode;
+}
+}
+
+/**
+ * The default MODE for this option
+ */
+public static final MODE DEFAULT_VALUE = MODE.LENIENT;
+
+private final MODE runtimeMode;
+
+public RuntimeModeOption(String runtimeMode) {
+MODE toSet = null;
+try {
+toSet = MODE.valueOf(runtimeMode);
+} catch (Exception e) {
+toSet = DEFAULT_VALUE;

Review Comment:
   `RuntimeModeOption(String)` uses `MODE.valueOf(runtimeMode)`, which only 
accepts enum constants ("STRICT"/"LENIENT"). With the documented system 
property values ("strict"/"lenient"), parsing falls into the exception path and 
silently defaults to LENIENT, so strict mode can never be enabled via property. 
Parse case-insensitively (e.g., normalize to upper-case) or map using 
`MODE.getMode()`.
   ```suggestion
   MODE toSet = DEFAULT_VALUE;
   if (runtimeMode != null) {
   for (MODE modeValue : MODE.values()) {
   if (modeValue.getMode().equalsIgnoreCase(runtimeMode) || 
modeValue.name().equalsIgnoreCase(runtimeMode)) {
   toSet = modeValue;
   break;
   }
   }
   ```



##
kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNInputRuntimeTest.java:
##
@@ -27,6 +27,7 @@
 import java.util.Set;
 import java.util.stream.Collectors;
 
+import org.junit.jupiter.api.Disabled;

Review Comment:
   Unused import `org.junit.jupiter.api.Disabled` will cause compilation to 
fail (javac errors on unused imports). Remove it or actually use `@Disabled` on 
a test.
   ```suggestion
   
   ```



##
kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNInputRuntimeTest.java:
##
@@ -697,7 +700,138 @@ void multipleInvalidElements(boolean 
useExecModelCompiler) {
 retrievedResult = dmnResult.getDecisionResultById(decision2SourceId);
 assertThat(retrievedResult).isNotNull();
 
assertThat(retrievedResult.getEvaluationStatus()).isEqualTo(DMNDecisionResult.DecisionEvaluationStatus.FAILED);
+}
+
+@ParameterizedTest
+@MethodSource("params")
+void errorHandlingWithDefaultMode(boolean useExecModelCompiler) {
+init(useExecModelCompiler);
+String nameSpace = 
"https://kie.org/dmn/_79591DB5-1EE1-4CBD-AA5D-2E3EDF31155E";;
+final DMNRuntime runtime = 
DMNRuntimeUtil.createRuntime("invalid_models/DMNv1_6/DMN-MultipleInvalidElements"
 +
+
".dmn", this.getClass());
+final DMNModel dmnModel = runtime.getModel(
+nameSpace,
+"DMN_8F7C4323-412A-4E0B-9AEF-0F24C8F55282");
+assertThat(dmnModel).isNotNull();
+
assertThat(dmnModel.hasErrors()).as(DMNRuntimeUtil.formatMessages(dmnModel.getMessages())).isFalse();
+final DMNContext dmnContext = DMNFactory.newContext();
+dmnContext.set("id", "_7273EA2E-2CC3-4012-8F87-39E310C8DF3C");
+dmnContext.set("Conditional Input", 107);
+dmnContext.set("New Input Data", );
+dmnContext.set("Score", 80);
+final DMNResult dmnResult = runtime.evaluateAll(dmnModel, dmnContext);
+
assertThat(dmnResult.hasErrors()).as(DMNRuntimeUtil.formatMessages(dmnResu

Re: [PR] [incubator-kie-issues#2015] Add error handling modes in DMN engine [incubator-kie-drools]

2025-07-07 Thread via GitHub


gitgabrio merged PR #6387:
URL: https://github.com/apache/incubator-kie-drools/pull/6387


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] [incubator-kie-issues#2015] Add error handling modes in DMN engine [incubator-kie-drools]

2025-07-03 Thread via GitHub


yesamer commented on code in PR #6387:
URL: 
https://github.com/apache/incubator-kie-drools/pull/6387#discussion_r2182593488


##
kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/BaseFEELFunction.java:
##
@@ -21,16 +21,15 @@
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
 import java.util.function.Function;
 import java.util.function.Supplier;
 import java.util.stream.Collectors;
 import java.util.stream.IntStream;
 import java.util.stream.Stream;
 
+import org.kie.dmn.api.core.DMNModel;
+import org.kie.dmn.api.core.DMNRuntime;

Review Comment:
   @gitgabrio Why you introduced those new imports?



##
kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/BaseFEELFunction.java:
##
@@ -21,16 +21,15 @@
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
+import java.util.*;

Review Comment:
   @gitgabrio Ouch!



##
kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/BaseFEELFunction.java:
##
@@ -44,6 +43,7 @@
 import org.kie.dmn.feel.runtime.events.InvalidParametersEvent;
 import org.kie.dmn.feel.util.BuiltInTypeUtils;
 import org.kie.dmn.feel.util.Either;
+import org.kie.dmn.model.api.Definitions;

Review Comment:
   @gitgabrio Same as above



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] [incubator-kie-issues#2015] Add error handling modes in DMN engine [incubator-kie-drools]

2025-07-02 Thread via GitHub


baldimir commented on code in PR #6387:
URL: 
https://github.com/apache/incubator-kie-drools/pull/6387#discussion_r2179985976


##
kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNCompilerTest.java:
##
@@ -508,6 +510,47 @@ void checkModelWithGroupNode(VariantTestConf conf) {
 
assertThat(dmnModel.hasErrors()).as(DMNRuntimeUtil.formatMessages(dmnModel.getMessages())).isFalse();
 }
 
+@ParameterizedTest
+@MethodSource("params")
+void errorHandlingWithDefaultMode(VariantTestConf conf) {
+testConfig = conf;
+String nameSpace = 
"https://kie.org/dmn/_79591DB5-1EE1-4CBD-AA5D-2E3EDF31155E";;
+final DMNRuntime runtime = 
DMNRuntimeUtil.createRuntime("invalid_models/DMNv1_6/DMN-MultipleInvalidElements.dmn",
 this.getClass());
+final DMNModel dmnModel = runtime.getModel(
+nameSpace,
+"DMN_8F7C4323-412A-4E0B-9AEF-0F24C8F55282");
+assertThat(dmnModel).isNotNull();
+
assertThat(dmnModel.hasErrors()).as(DMNRuntimeUtil.formatMessages(dmnModel.getMessages())).isFalse();
+}
+
+@ParameterizedTest
+@MethodSource("params")
+void errorHandlingWithLenientMode(VariantTestConf conf) {
+testConfig = conf;
+String nameSpace = 
"https://kie.org/dmn/_79591DB5-1EE1-4CBD-AA5D-2E3EDF31155E";;
+final DMNRuntime runtime = 
DMNRuntimeUtil.createRuntime("invalid_models/DMNv1_6/DMN-MultipleInvalidElements.dmn",
 this.getClass());
+((DMNRuntimeImpl)runtime).setOption(new 
RuntimeModeOption(RuntimeModeOption.MODE.LENIENT));
+final DMNModel dmnModel = runtime.getModel(
+nameSpace,
+"DMN_8F7C4323-412A-4E0B-9AEF-0F24C8F55282");
+assertThat(dmnModel).isNotNull();
+
assertThat(dmnModel.hasErrors()).as(DMNRuntimeUtil.formatMessages(dmnModel.getMessages())).isFalse();
+}
+
+@ParameterizedTest
+@MethodSource("params")
+void errorHandlingWithStrictMode(VariantTestConf conf) {
+testConfig = conf;
+String nameSpace = 
"https://kie.org/dmn/_79591DB5-1EE1-4CBD-AA5D-2E3EDF31155E";;
+final DMNRuntime runtime = 
DMNRuntimeUtil.createRuntime("invalid_models/DMNv1_6/DMN-MultipleInvalidElements.dmn",
 this.getClass());
+((DMNRuntimeImpl)runtime).setOption(new 
RuntimeModeOption(RuntimeModeOption.MODE.LENIENT));

Review Comment:
   This is setting the LENIENT, not STRICT mode. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] [incubator-kie-issues#2015] Add error handling modes in DMN engine [incubator-kie-drools]

2025-07-02 Thread via GitHub


gitgabrio commented on code in PR #6387:
URL: 
https://github.com/apache/incubator-kie-drools/pull/6387#discussion_r2180005721


##
kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNCompilerTest.java:
##
@@ -508,6 +510,47 @@ void checkModelWithGroupNode(VariantTestConf conf) {
 
assertThat(dmnModel.hasErrors()).as(DMNRuntimeUtil.formatMessages(dmnModel.getMessages())).isFalse();
 }
 
+@ParameterizedTest
+@MethodSource("params")
+void errorHandlingWithDefaultMode(VariantTestConf conf) {
+testConfig = conf;
+String nameSpace = 
"https://kie.org/dmn/_79591DB5-1EE1-4CBD-AA5D-2E3EDF31155E";;
+final DMNRuntime runtime = 
DMNRuntimeUtil.createRuntime("invalid_models/DMNv1_6/DMN-MultipleInvalidElements.dmn",
 this.getClass());
+final DMNModel dmnModel = runtime.getModel(
+nameSpace,
+"DMN_8F7C4323-412A-4E0B-9AEF-0F24C8F55282");
+assertThat(dmnModel).isNotNull();
+
assertThat(dmnModel.hasErrors()).as(DMNRuntimeUtil.formatMessages(dmnModel.getMessages())).isFalse();
+}
+
+@ParameterizedTest
+@MethodSource("params")
+void errorHandlingWithLenientMode(VariantTestConf conf) {
+testConfig = conf;
+String nameSpace = 
"https://kie.org/dmn/_79591DB5-1EE1-4CBD-AA5D-2E3EDF31155E";;
+final DMNRuntime runtime = 
DMNRuntimeUtil.createRuntime("invalid_models/DMNv1_6/DMN-MultipleInvalidElements.dmn",
 this.getClass());
+((DMNRuntimeImpl)runtime).setOption(new 
RuntimeModeOption(RuntimeModeOption.MODE.LENIENT));
+final DMNModel dmnModel = runtime.getModel(
+nameSpace,
+"DMN_8F7C4323-412A-4E0B-9AEF-0F24C8F55282");
+assertThat(dmnModel).isNotNull();
+
assertThat(dmnModel.hasErrors()).as(DMNRuntimeUtil.formatMessages(dmnModel.getMessages())).isFalse();
+}
+
+@ParameterizedTest
+@MethodSource("params")
+void errorHandlingWithStrictMode(VariantTestConf conf) {
+testConfig = conf;
+String nameSpace = 
"https://kie.org/dmn/_79591DB5-1EE1-4CBD-AA5D-2E3EDF31155E";;
+final DMNRuntime runtime = 
DMNRuntimeUtil.createRuntime("invalid_models/DMNv1_6/DMN-MultipleInvalidElements.dmn",
 this.getClass());
+((DMNRuntimeImpl)runtime).setOption(new 
RuntimeModeOption(RuntimeModeOption.MODE.LENIENT));

Review Comment:
   ouch



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]