Merge pull request #442 from sartography/bug/deepcopy-validation

Just kidding. We should make deepcopy and put in fake data 4 valdiation
This commit is contained in:
Dan Funk 2021-12-17 11:06:39 -05:00 committed by GitHub
commit 469cd2377c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 2 deletions

View File

@ -376,10 +376,15 @@ class WorkflowService(object):
def evaluate_property(property_name, field, task):
expression = field.get_property(property_name)
data = task.data
data = copy.deepcopy(task.data)
# If there's a field key with no initial value, give it one (None)
for field in task.task_spec.form.fields:
if field.id not in data:
data[field.id] = None
if field.has_property(Task.FIELD_PROP_REPEAT):
# Then you must evaluate the expression based on the data within the group, if that data exists.
# There may not be data available in the group, if no groups where added
# There may not be data available in the group, if no groups were added
group = field.get_property(Task.FIELD_PROP_REPEAT)
if group in task.data and len(task.data[group]) > 0:
# Here we must make the current group data top level (as it would be in a repeat section) but
@ -391,6 +396,9 @@ class WorkflowService(object):
else:
return None # We may not have enough information to process this
if not field.has_property(Task.FIELD_PROP_REPEAT):
new_data = copy.deepcopy(task.data)
try:
return task.workflow.script_engine._evaluate(expression, **data)
except Exception as e: