From ffb468d6bb8afc932c97a980620142c149231f45 Mon Sep 17 00:00:00 2001 From: Jon Herron Date: Thu, 9 Feb 2023 09:45:31 -0500 Subject: [PATCH] Fix bug where deletes from the environment were not removed from the task data as well --- .../services/process_instance_processor.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_processor.py b/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_processor.py index d8bfeba78..977bd61bd 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_processor.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_processor.py @@ -207,6 +207,13 @@ class NonTaskDataBasedScriptEngineEnvironment(BasePythonScriptEngineEnvironment) self.state.update(context) exec(script, self.state) # noqa + # since the task data is not directly mutated when the script executes, need to determine which keys + # have been deleted from the environment and remove them from task data if present. + context_keys_to_drop = context.keys() - self.state.keys() + + for key_to_drop in context_keys_to_drop: + context.pop(key_to_drop) + self.state = self._user_defined_state(external_methods) # the task data needs to be updated with the current state so data references can be resolved properly.