Improve error message for YAQL task function

Improve the error message in case a non existing task name is passed
to the "task" YAQL function

Change-Id: I93a33365779ba2a5301431c6769697d8b4861fae
Closes-Bug: 1520930
This commit is contained in:
Moshe Elisha 2015-11-29 13:40:23 +00:00
parent b9c7f66345
commit 255fb91ad5
3 changed files with 27 additions and 2 deletions

View File

@ -830,7 +830,7 @@ Example:
    - radix: 16
  output:
    uuid: <% task(generated_uuid).result %>
    uuid: <% task(generate_uuid_task).result %>
  tasks:
    generate_uuid_task:

View File

@ -109,3 +109,28 @@ class YAQLFunctionsEngineTest(engine_test_base.EngineTestCase):
},
task2.published
)
def test_task_function_non_existing(self):
wf_text = """---
version: '2.0'
wf:
type: direct
output:
task_name: <% task(non_existing_task).name %>
tasks:
task1:
action: std.noop
"""
wf_service.create_workflows(wf_text)
wf_ex = self.engine.start_workflow('wf', {})
self._await(lambda: self.is_execution_error(wf_ex.id))
wf_ex = db_api.get_workflow_execution(wf_ex.id)
self.assertEqual(states.ERROR, wf_ex.state)
self.assertIn('non_existing_task', wf_ex.state_info)

View File

@ -75,7 +75,7 @@ def task_(context, task_name):
# TODO(rakhmerov): Account for multiple executions (i.e. in case of
# cycles).
task_ex = task_execs[-1]
task_ex = task_execs[-1] if len(task_execs) > 0 else None
if not task_ex:
raise ValueError(