diff --git a/mistral/engine/task_handler.py b/mistral/engine/task_handler.py index c5272c92d..562d1215c 100644 --- a/mistral/engine/task_handler.py +++ b/mistral/engine/task_handler.py @@ -106,9 +106,9 @@ def _on_action_complete(action_ex): except exc.MistralException as e: wf_ex = task_ex.workflow_execution - msg = ("Failed to handle action completion [wf=%s, task=%s," - " action=%s]: %s\n%s" % - (wf_ex.name, task_ex.name, action_ex.name, e, tb.format_exc())) + msg = ("Failed to handle action completion [error=%s, wf=%s, task=%s," + " action=%s]:\n%s" % + (e, wf_ex.name, task_ex.name, action_ex.name, tb.format_exc())) LOG.error(msg) @@ -184,8 +184,8 @@ def complete_task(task_ex, state, state_info): wf_ex = task_ex.workflow_execution msg = ( - "Failed to complete task [wf=%s, task=%s]: %s\n%s" % - (wf_ex, task_ex.name, e, tb.format_exc()) + "Failed to complete task [error=%s, wf=%s, task=%s]:\n%s" % + (e, wf_ex, task_ex.name, tb.format_exc()) ) LOG.error(msg) diff --git a/mistral/tests/unit/engine/test_error_handling.py b/mistral/tests/unit/engine/test_error_handling.py index 193c3c47f..3a93c47ba 100644 --- a/mistral/tests/unit/engine/test_error_handling.py +++ b/mistral/tests/unit/engine/test_error_handling.py @@ -474,3 +474,67 @@ class ErrorHandlingEngineTest(base.EngineTestCase): self.assertIsNotNone(state_info) self.assertTrue(state_info.find('error=') > 0) self.assertTrue(state_info.find('error=') < state_info.find('wf=')) + + def test_error_message_format_on_action_complete(self): + wf_text = """ + version: '2.0' + + wf: + tasks: + task1: + action: std.noop + publish: + my_var: <% invalid_yaql_function() %> + """ + + 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) + + task_ex = wf_ex.task_executions[0] + + state_info = task_ex.state_info + + print(state_info) + + self.assertIsNotNone(state_info) + self.assertTrue(state_info.find('error=') > 0) + self.assertTrue(state_info.find('error=') < state_info.find('wf=')) + + def test_error_message_format_complete_task(self): + wf_text = """ + version: '2.0' + + wf: + tasks: + task1: + action: std.noop + wait-after: 1 + on-success: + - task2: <% invalid_yaql_function() %> + + task2: + action: std.noop + """ + + 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) + + task_ex = wf_ex.task_executions[0] + + state_info = task_ex.state_info + + self.assertIsNotNone(state_info) + self.assertTrue(state_info.find('error=') > 0) + self.assertTrue(state_info.find('error=') < state_info.find('wf=')) diff --git a/mistral/tests/unit/engine/test_execution_fields_size_limitation.py b/mistral/tests/unit/engine/test_execution_fields_size_limitation.py index 7c6c48c64..68de8996e 100644 --- a/mistral/tests/unit/engine/test_execution_fields_size_limitation.py +++ b/mistral/tests/unit/engine/test_execution_fields_size_limitation.py @@ -195,10 +195,12 @@ class ExecutionFieldsSizeLimitTest(base.EngineTestCase): wf_ex = db_api.get_workflow_execution(wf_ex.id) self.assertIn( - 'Failed to handle action completion [wf=wf, task=task1', + 'Failed to handle action completion [error=Size of', wf_ex.state_info ) + self.assertIn('wf=wf, task=task1', wf_ex.state_info) + task_ex = self._assert_single_item(wf_ex.task_executions, name='task1') self.assertIn(