Minor stuff to help digging into validation of current workflows.

This commit is contained in:
Dan 2022-02-18 17:20:04 -05:00
parent a7f591d2ac
commit c3e52f960b
4 changed files with 10 additions and 2463 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,6 @@
import logging.config import logging.config
import os import os
import traceback
import click import click
import sentry_sdk import sentry_sdk
@ -151,5 +152,7 @@ def validate_all(study_id, category=None, spec_id=None):
continue continue
except Exception as e: except Exception as e:
print(f"Unexpected Error ({e.__class__.__name__}), {e} validate workflow {spec.id} in Category {spec.category.display_name}") print(f"Unexpected Error ({e.__class__.__name__}), {e} validate workflow {spec.id} in Category {spec.category.display_name}")
# printing stack trace
traceback.print_exc()
print(e) print(e)
continue return

View File

@ -237,7 +237,7 @@ class WorkflowProcessor(object):
elif file.type == FileType.dmn: elif file.type == FileType.dmn:
dmn: etree.Element = etree.fromstring(data) dmn: etree.Element = etree.fromstring(data)
parser.add_dmn_xml(dmn, filename=file.name) parser.add_dmn_xml(dmn, filename=file.name)
if workflow_spec_info.primary_process_id is None: if workflow_spec_info.primary_process_id is None or workflow_spec_info.primary_process_id == "":
raise (ApiError(code="no_primary_bpmn_error", raise (ApiError(code="no_primary_bpmn_error",
message="There is no primary BPMN model defined for workflow %s" % workflow_spec_info.id)) message="There is no primary BPMN model defined for workflow %s" % workflow_spec_info.id))
try: try:

View File

@ -16,6 +16,7 @@ from SpiffWorkflow.bpmn.specs.ScriptTask import ScriptTask
from SpiffWorkflow.bpmn.specs.UserTask import UserTask from SpiffWorkflow.bpmn.specs.UserTask import UserTask
from SpiffWorkflow.bpmn.specs.events import EndEvent, StartEvent from SpiffWorkflow.bpmn.specs.events import EndEvent, StartEvent
from SpiffWorkflow.dmn.specs.BusinessRuleTask import BusinessRuleTask from SpiffWorkflow.dmn.specs.BusinessRuleTask import BusinessRuleTask
from SpiffWorkflow.exceptions import WorkflowTaskExecException
from SpiffWorkflow.specs import CancelTask, StartTask from SpiffWorkflow.specs import CancelTask, StartTask
from SpiffWorkflow.util.deep_merge import DeepMerge from SpiffWorkflow.util.deep_merge import DeepMerge
from SpiffWorkflow.util.metrics import timeit from SpiffWorkflow.util.metrics import timeit
@ -468,8 +469,10 @@ class WorkflowService(object):
# default = WorkflowService.evaluate_property(Task.FIELD_PROP_VALUE_EXPRESSION, field, task) # default = WorkflowService.evaluate_property(Task.FIELD_PROP_VALUE_EXPRESSION, field, task)
default = None default = None
if field.default_value is not None: if field.default_value is not None:
default = task.workflow.script_engine._evaluate(field.default_value, data) try:
default = task.workflow.script_engine._evaluate(field.default_value, data)
except Exception as e:
raise WorkflowTaskExecException(task, "invalid_default", e)
# If no default exists, return None # If no default exists, return None
# Note: if default is False, we don't want to execute this code # Note: if default is False, we don't want to execute this code
if default is None or (isinstance(default, str) and default.strip() == ''): if default is None or (isinstance(default, str) and default.strip() == ''):