Re: [PR] [incubator-kie-issues#2015] Add error handling modes in DMN engine [incubator-kie-drools]
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]
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]
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]
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]
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]
[PR] [incubator-kie-issues#2015] Add error handling modes in DMN engine [incubator-kie-drools]
gitgabrio opened a new pull request, #6387: URL: https://github.com/apache/incubator-kie-drools/pull/6387 Fixes https://github.com/apache/incubator-kie-issues/issues/2015 This PR: 1. define RuntimeModeOption enum 2. bound that enume to the system property `org.kie.dmn.runtime.mode` (possible values: `lenient` `strict` - default to `lenient`) 3. use it inside DMNRuntimeIMpl, during model evaluation 4. implement fast-fail for strict mode 5. add tests for that 6. introduce a small refactoring to split evaluateDecision method DO-NOT-MERGE - this PR has to be merged after https://github.com/apache/incubator-kie-drools/pull/6385 How to replicate CI configuration locally? Build Chain tool does "simple" maven build(s), the builds are just Maven commands, but because the repositories relates and depends on each other and any change in API or class method could affect several of those repositories there is a need to use [build-chain tool](https://github.com/kiegroup/github-action-build-chain) to handle cross repository builds and be sure that we always use latest version of the code for each repository. [build-chain tool](https://github.com/kiegroup/github-action-build-chain) is a build tool which can be used on command line locally or in Github Actions workflow(s), in case you need to change multiple repositories and send multiple dependent pull requests related with a change you can easily reproduce the same build by executing it on Github hosted environment or locally in your development environment. See [local execution](https://github.com/kiegroup/github-action-build-chain#local-execution) details to get more information about it. How to retest this PR or trigger a specific build: - for pull request and downstream checks - Push a new commit to the PR. An empty commit would be enough. - for a full downstream build - for github actions job: add the label `run_fdb` - for Jenkins PR check only - If you are an ASF committer for KIE podling, login to Jenkins (https://ci-builds.apache.org/job/KIE/job/drools/), go to the specific PR job, and click on `Build Now` button. -- 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]
