From a830657ebd8aada0a4c669a33ad9a207138e712b Mon Sep 17 00:00:00 2001 From: mike cullerton Date: Mon, 21 Feb 2022 10:17:01 -0500 Subject: [PATCH 1/3] raise ApiError when isExecutable tag is missing. Unsure how this would actually happen, since it should get set to False if box is unchecked. --- crc/services/spec_file_service.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crc/services/spec_file_service.py b/crc/services/spec_file_service.py index 74b4615d..1a39eedc 100644 --- a/crc/services/spec_file_service.py +++ b/crc/services/spec_file_service.py @@ -113,6 +113,13 @@ class SpecFileService(FileSystemService): except etree.XMLSyntaxError as xse: raise ApiError("invalid_xml", "Failed to parse xml: " + str(xse), file_name=file_name) + except ValidationException as ve: + if ve.args[0].find('No executable process tag found') >= 0: + raise ApiError(code='missing_executable_option', + message='No executable process tag found. Please make sure the Executable option is set in the workflow.') + else: + raise ApiError(code='validation_error', + message=f'There was an error validating your workflow. Original message is: {ve}') else: raise ApiError("invalid_xml", "Only a BPMN can be the primary file.", file_name=file_name) From 1cd3be70a7f7ea31582d7fabdd82079acb179658 Mon Sep 17 00:00:00 2001 From: mike cullerton Date: Mon, 21 Feb 2022 10:17:18 -0500 Subject: [PATCH 2/3] Test for bug fix --- .../missing_executable_tag.bpmn | 39 +++++++++++++++++++ .../test_workflow_missing_executable_tag.py | 12 ++++++ 2 files changed, 51 insertions(+) create mode 100644 tests/data/missing_executable_tag/missing_executable_tag.bpmn create mode 100644 tests/workflow/test_workflow_missing_executable_tag.py diff --git a/tests/data/missing_executable_tag/missing_executable_tag.bpmn b/tests/data/missing_executable_tag/missing_executable_tag.bpmn new file mode 100644 index 00000000..9c0af5c5 --- /dev/null +++ b/tests/data/missing_executable_tag/missing_executable_tag.bpmn @@ -0,0 +1,39 @@ + + + + + Flow_0djwo51 + + + + Flow_19hnovy + + + + ## Hello World + Flow_0djwo51 + Flow_19hnovy + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/workflow/test_workflow_missing_executable_tag.py b/tests/workflow/test_workflow_missing_executable_tag.py new file mode 100644 index 00000000..7e6d933f --- /dev/null +++ b/tests/workflow/test_workflow_missing_executable_tag.py @@ -0,0 +1,12 @@ +from tests.base_test import BaseTest + +from crc.api.common import ApiError + + +class TestMissingExecutable(BaseTest): + + def test_missing_executable(self): + with self.assertRaises(ApiError) as ae: + self.create_workflow('missing_executable_tag') + self.assertEqual('No executable process tag found. Please make sure the Executable option is set in the workflow.', + ae.exception.message) From 23a43c04720bdea100a0a781a52ace494fe220b1 Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 23 Feb 2022 11:53:24 -0500 Subject: [PATCH 3/3] fix to assure we produce a usable error message --- crc/services/workflow_service.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crc/services/workflow_service.py b/crc/services/workflow_service.py index ebb260d8..eba34ffd 100755 --- a/crc/services/workflow_service.py +++ b/crc/services/workflow_service.py @@ -842,7 +842,10 @@ class WorkflowService(object): try: return JinjaService.get_content(raw_doc, spiff_task.data) except jinja2.exceptions.TemplateSyntaxError as tse: - error_line = documentation.splitlines()[tse.lineno - 1] + lines = tse.source.splitlines() + error_line = "" + if len(lines) >= tse.lineno - 1: + error_line = tse.source.splitlines()[tse.lineno - 1] raise ApiError.from_task(code="template_error", message="Jinja Template Error: %s" % str(tse), task=spiff_task, line_number=tse.lineno, error_line=error_line) except jinja2.exceptions.TemplateError as te: