diff --git a/mistral/executors/default_executor.py b/mistral/executors/default_executor.py index 661901abb..2de8dc874 100644 --- a/mistral/executors/default_executor.py +++ b/mistral/executors/default_executor.py @@ -123,13 +123,13 @@ class DefaultExecutor(base.Executor): except BaseException as e: msg = ( - "The action raised an exception [action_ex_id=%s, " - "action_cls='%s', attributes='%s', params='%s']\n %s" % ( + "The action raised an exception [action_ex_id=%s, msg='%s', " + "action_cls='%s', attributes='%s', params='%s']" % ( action_ex_id, + e, action_cls, action_cls_attrs, - params, - e + params ) ) diff --git a/mistral/tests/unit/engine/test_error_handling.py b/mistral/tests/unit/engine/test_error_handling.py index f73fd3781..94e73002e 100644 --- a/mistral/tests/unit/engine/test_error_handling.py +++ b/mistral/tests/unit/engine/test_error_handling.py @@ -821,3 +821,35 @@ class ErrorHandlingEngineTest(base.EngineTestCase): task_ex = wf_ex.task_executions[0] self.assertDictEqual({'my_var': 2}, task_ex.published) + + def test_action_error_message_format(self): + wf_text = """--- + version: '2.0' + + wf: + tasks: + task1: + action: std.fail + """ + + wf_service.create_workflows(wf_text) + + wf_ex = self.engine.start_workflow('wf') + + self.await_workflow_error(wf_ex.id) + + with db_api.transaction(): + wf_ex = db_api.get_workflow_execution(wf_ex.id) + + self.assertEqual(1, len(wf_ex.task_executions)) + + task_ex = wf_ex.task_executions[0] + + expected = ( + "The action raised an exception [action_ex_id=%s, " + "msg='Fail action expected exception.'" + ) % task_ex.action_executions[0].id + + # Making sure that the actual error message goes before + # other debugging information. + self.assertTrue(task_ex.state_info.startswith(expected)) diff --git a/releasenotes/notes/include_root_cause_of_action_error_first-4a730a7cbc36f375.yaml b/releasenotes/notes/include_root_cause_of_action_error_first-4a730a7cbc36f375.yaml new file mode 100644 index 000000000..d3b6233c6 --- /dev/null +++ b/releasenotes/notes/include_root_cause_of_action_error_first-4a730a7cbc36f375.yaml @@ -0,0 +1,13 @@ +--- + +fixes: + - | + Some users rely on the presence of the root error related to + running an action and it's not convenient that it is now in + the end of the string, e.g. if we look at the corresponding + task execution "state_info" field. Now a cause error message + is included in the beginning of the resulting error string + returned by the action executor so that it's clearly visible. + This message can be also truncated in some cases (depending on + the config option) so we need to make sure we keep the cause + error message.