From 5baf0faeb3e285a88e8bce4e893791a2d0434b8a Mon Sep 17 00:00:00 2001 From: brig Date: Fri, 21 Feb 2025 02:30:50 -0500 Subject: [PATCH] runtimev2: error message for process arguments evaluation --- .../runtime/v2/runner/LogExceptionsTest.java | 28 +++++++++++++++++++ .../invalidArgs/concord.yaml | 3 ++ .../concord/runtime/v2/runner/Runner.java | 22 +++++++++++++-- 3 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 runtime/v2/runner-test/src/test/resources/com/walmartlabs/concord/runtime/v2/runner/logExceptionTests/invalidArgs/concord.yaml diff --git a/runtime/v2/runner-test/src/test/java/com/walmartlabs/concord/runtime/v2/runner/LogExceptionsTest.java b/runtime/v2/runner-test/src/test/java/com/walmartlabs/concord/runtime/v2/runner/LogExceptionsTest.java index 681e1663b4..85e48e4c34 100644 --- a/runtime/v2/runner-test/src/test/java/com/walmartlabs/concord/runtime/v2/runner/LogExceptionsTest.java +++ b/runtime/v2/runner-test/src/test/java/com/walmartlabs/concord/runtime/v2/runner/LogExceptionsTest.java @@ -278,4 +278,32 @@ public void noStacktraceForUserDefinedExceptionFromTaskParallelParallel() throws assertNoLog(runtime.lastLog(), ".*" + quote("com.walmartlabs.concord.svm.ParallelExecutionException") + ".*"); assertNoLog(runtime.lastLog(), ".*" + quote("at com.walmartlabs.concord.runtime.v2.runner.vm.JoinCommand.execute") + ".*"); } + + + @Test + public void noStackTraceForArgsEvalError() throws Exception { + runtime.deploy("logExceptionTests/invalidArgs"); + + runtime.save(ProcessConfiguration.builder() + .putArguments("name", "${undefinedVariableName}") + .build()); + + try { + runtime.run(); + fail("Exception expected"); + } catch (Exception e) { + // ignore + } + + var errorMessage = "[ERROR] Error while evaluating process arguments: while evaluating expression " + + "'${undefinedVariableName}': Can't find a variable 'undefinedVariableName'. " + + "Check if it is defined in the current scope. " + + "Details: ELResolver cannot handle a null base Object with identifier 'undefinedVariableName'"; + + // error + assertLog(runtime.lastLog(), ".*" + quote(errorMessage) + ".*"); + + // no stacktrace + assertNoLog(runtime.lastLog(), ".*" + quote("at com.walmartlabs.concord.runtime.v2") + ".*"); + } } diff --git a/runtime/v2/runner-test/src/test/resources/com/walmartlabs/concord/runtime/v2/runner/logExceptionTests/invalidArgs/concord.yaml b/runtime/v2/runner-test/src/test/resources/com/walmartlabs/concord/runtime/v2/runner/logExceptionTests/invalidArgs/concord.yaml new file mode 100644 index 0000000000..3272555d79 --- /dev/null +++ b/runtime/v2/runner-test/src/test/resources/com/walmartlabs/concord/runtime/v2/runner/logExceptionTests/invalidArgs/concord.yaml @@ -0,0 +1,3 @@ +flows: + default: + - log: "OK" diff --git a/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/Runner.java b/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/Runner.java index d8aa4447fd..815145c04f 100644 --- a/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/Runner.java +++ b/runtime/v2/runner/src/main/java/com/walmartlabs/concord/runtime/v2/runner/Runner.java @@ -79,7 +79,12 @@ public ProcessSnapshot start(ProcessConfiguration processConfiguration, ProcessD VM vm = createVM(processDefinition); // update the global variables using the input map by running a special command - vm.run(state, new UpdateLocalsCommand(input)); // TODO merge with the cfg's arguments + try { + vm.run(state, new UpdateLocalsCommand(input)); // TODO merge with the cfg's arguments + } catch (RuntimeException e) { + log.error("Error while evaluating process arguments: {}", e.getMessage(), e); + throw e; + } // start the normal execution vm.start(state); @@ -105,7 +110,12 @@ public ProcessSnapshot resume(ProcessSnapshot snapshot, Set eventRefs, M .filter(kv -> eventRefs.contains(kv.getValue())) .map(Map.Entry::getKey) .collect(Collectors.toList()); - vm.run(state, new UpdateLocalsCommand(input, resumingThreads)); + try { + vm.run(state, new UpdateLocalsCommand(input, resumingThreads)); + } catch (RuntimeException e) { + log.error("Error while evaluating resume arguments: {}", e.getMessage(), e); + throw e; + } // resume normally vm.resume(state, eventRefs); @@ -126,7 +136,13 @@ public ProcessSnapshot resume(ProcessSnapshot snapshot, Map inpu VM vm = createVM(snapshot.processDefinition()); // update the global variables using the input map by running a special command - vm.run(state, new UpdateLocalsCommand(input)); + try { + vm.run(state, new UpdateLocalsCommand(input)); + } catch (RuntimeException e) { + log.error("Error while evaluating resume arguments: {}", e.getMessage(), e); + throw e; + } + // continue as usual vm.start(state);