Skip to content
This repository was archived by the owner on Dec 13, 2023. It is now read-only.

Commit ed638cd

Browse files
committed
For INLINE task, corrected reasonForIncompletion field to include the script error message.
1 parent 0388b12 commit ed638cd

File tree

3 files changed

+19
-15
lines changed

3 files changed

+19
-15
lines changed

core/src/main/java/com/netflix/conductor/core/execution/evaluators/JavascriptEvaluator.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@ public Object evaluate(String expression, Object input) {
3636
LOGGER.debug("Javascript evaluator -- result: {}", result);
3737
return result;
3838
} catch (ScriptException e) {
39-
String errorMsg = String.format("Error while evaluating script: %s", expression);
40-
LOGGER.error(errorMsg, e);
41-
throw new TerminateWorkflowException(errorMsg);
39+
LOGGER.error("Error while evaluating script: {}", expression, e);
40+
throw new TerminateWorkflowException(e.getMessage());
4241
}
4342
}
4443
}

core/src/main/java/com/netflix/conductor/core/execution/tasks/Inline.java

+14-9
Original file line numberDiff line numberDiff line change
@@ -82,38 +82,43 @@ public boolean execute(
8282
taskOutput.put("result", evalResult);
8383
task.setStatus(TaskModel.Status.COMPLETED);
8484
} catch (Exception e) {
85+
String errorMessage = e.getCause() != null ? e.getCause().getMessage() : e.getMessage();
8586
LOGGER.error(
8687
"Failed to execute Inline Task: {} in workflow: {}",
8788
task.getTaskId(),
8889
workflow.getWorkflowId(),
8990
e);
90-
task.setStatus(TaskModel.Status.FAILED);
91-
task.setReasonForIncompletion(e.getMessage());
92-
taskOutput.put(
93-
"error", e.getCause() != null ? e.getCause().getMessage() : e.getMessage());
91+
// TerminateWorkflowException is thrown when the script evaluation fails
92+
// Retry will result in the same error, so FAILED_WITH_TERMINAL_ERROR status is used.
93+
task.setStatus(
94+
e instanceof TerminateWorkflowException
95+
? TaskModel.Status.FAILED_WITH_TERMINAL_ERROR
96+
: TaskModel.Status.FAILED);
97+
task.setReasonForIncompletion(errorMessage);
98+
taskOutput.put("error", errorMessage);
9499
}
95100

96101
return true;
97102
}
98103

99104
private void checkEvaluatorType(String evaluatorType) {
100105
if (StringUtils.isBlank(evaluatorType)) {
101-
LOGGER.error("Empty {} in Inline task. ", QUERY_EVALUATOR_TYPE);
106+
LOGGER.error("Empty {} in INLINE task. ", QUERY_EVALUATOR_TYPE);
102107
throw new TerminateWorkflowException(
103108
"Empty '"
104109
+ QUERY_EVALUATOR_TYPE
105-
+ "' in Inline task's input parameters. A non-empty String value must be provided.");
110+
+ "' in INLINE task's input parameters. A non-empty String value must be provided.");
106111
}
107112
if (evaluators.get(evaluatorType) == null) {
108-
LOGGER.error("Evaluator {} for Inline task not registered", evaluatorType);
113+
LOGGER.error("Evaluator {} for INLINE task not registered", evaluatorType);
109114
throw new TerminateWorkflowException(
110-
"Unknown evaluator '" + evaluatorType + "' in Inline task.");
115+
"Unknown evaluator '" + evaluatorType + "' in INLINE task.");
111116
}
112117
}
113118

114119
private void checkExpression(String expression) {
115120
if (StringUtils.isBlank(expression)) {
116-
LOGGER.error("Empty {} in Inline task. ", QUERY_EXPRESSION_PARAMETER);
121+
LOGGER.error("Empty {} in INLINE task. ", QUERY_EXPRESSION_PARAMETER);
117122
throw new TerminateWorkflowException(
118123
"Empty '"
119124
+ QUERY_EXPRESSION_PARAMETER

core/src/test/java/com/netflix/conductor/core/execution/tasks/InlineTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public void testInlineTaskValidationFailures() {
4444
TaskModel task = new TaskModel();
4545
task.getInputData().putAll(inputObj);
4646
inline.execute(workflow, task, executor);
47-
assertEquals(TaskModel.Status.FAILED, task.getStatus());
47+
assertEquals(TaskModel.Status.FAILED_WITH_TERMINAL_ERROR, task.getStatus());
4848
assertEquals(
4949
"Empty 'expression' in Inline task's input parameters. A non-empty String value must be provided.",
5050
task.getReasonForIncompletion());
@@ -57,9 +57,9 @@ public void testInlineTaskValidationFailures() {
5757
task = new TaskModel();
5858
task.getInputData().putAll(inputObj);
5959
inline.execute(workflow, task, executor);
60-
assertEquals(TaskModel.Status.FAILED, task.getStatus());
60+
assertEquals(TaskModel.Status.FAILED_WITH_TERMINAL_ERROR, task.getStatus());
6161
assertEquals(
62-
"Empty 'evaluatorType' in Inline task's input parameters. A non-empty String value must be provided.",
62+
"Empty 'evaluatorType' in INLINE task's input parameters. A non-empty String value must be provided.",
6363
task.getReasonForIncompletion());
6464
}
6565

0 commit comments

Comments
 (0)