diff --git a/mistral/tests/unit/engine/test_yaql_functions.py b/mistral/tests/unit/engine/test_yaql_functions.py index c3a6c6828..bfa702773 100644 --- a/mistral/tests/unit/engine/test_yaql_functions.py +++ b/mistral/tests/unit/engine/test_yaql_functions.py @@ -293,6 +293,34 @@ class YAQLFunctionsEngineTest(engine_test_base.EngineTestCase): self._assert_single_item(wf_ex.task_executions, name='task1') self._assert_single_item(wf_ex.task_executions, name='task2') + def test_task_function_no_name_when_calculating_end_tasks(self): + wf_text = """--- + version: '2.0' + + wf: + tasks: + task1: + action: std.fail error_data="Some data" + on-error: + - task2: <% task().result != '' %> + + task2: + action: std.echo output=2 + """ + + wf_service.create_workflows(wf_text) + + wf_ex = self.engine.start_workflow('wf') + + self.await_workflow_success(wf_ex.id) + + with db_api.transaction(): + wf_ex = db_api.get_workflow_execution(wf_ex.id) + + self.assertEqual(2, len(wf_ex.task_executions)) + self._assert_single_item(wf_ex.task_executions, name='task1') + self._assert_single_item(wf_ex.task_executions, name='task2') + def test_uuid_function(self): wf_text = """--- version: '2.0' diff --git a/mistral/workflow/direct_workflow.py b/mistral/workflow/direct_workflow.py index d19e318b2..b804914b2 100644 --- a/mistral/workflow/direct_workflow.py +++ b/mistral/workflow/direct_workflow.py @@ -198,6 +198,7 @@ class DirectWorkflowController(base.WorkflowController): def all_errors_handled(self): for t_ex in lookup_utils.find_error_task_executions(self.wf_ex.id): ctx_view = data_flow.ContextView( + data_flow.get_current_task_dict(t_ex), data_flow.evaluate_task_outbound_context(t_ex), data_flow.get_workflow_environment_dict(self.wf_ex), self.wf_ex.context, @@ -230,9 +231,7 @@ class DirectWorkflowController(base.WorkflowController): ) for batch in batches: - yield list( - filter(is_end_task, batch) - ) + yield list(filter(is_end_task, batch)) def may_complete_workflow(self, task_ex): res = super(DirectWorkflowController, self).may_complete_workflow( diff --git a/releasenotes/notes/fix_task_function-04b83ada20a71f12.yaml b/releasenotes/notes/fix_task_function-04b83ada20a71f12.yaml new file mode 100644 index 000000000..dca7f1061 --- /dev/null +++ b/releasenotes/notes/fix_task_function-04b83ada20a71f12.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + "__task_execution" wasn't always included into the expression data + context so the function task() didn't work properly. + Fixes [`bug 1823875 `_]