Merge pull request #135 from sartography/bug/len

This should fix the len issue - though there may be better ways to fix
This commit is contained in:
Dan Funk 2023-02-13 10:38:32 -05:00 committed by GitHub
commit 69f85aad6b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 12 deletions

View File

@ -125,6 +125,7 @@ def process_instance_run(
raise e
except Exception as e:
ErrorHandlingService().handle_error(processor, e)
# fixme: this is going to point someone to the wrong task - it's misinformation for errors in sub-processes
task = processor.bpmn_process_instance.last_task
raise ApiError.from_task(
error_code="unknown_exception",

View File

@ -208,20 +208,21 @@ class NonTaskDataBasedScriptEngineEnvironment(BasePythonScriptEngineEnvironment)
self.state.update(self.globals)
self.state.update(external_methods or {})
self.state.update(context)
exec(script, self.state) # noqa
try:
exec(script, self.state) # noqa
finally:
# 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()
# 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)
for key_to_drop in context_keys_to_drop:
context.pop(key_to_drop)
self.state = self._user_defined_state(external_methods)
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.
# the state will be removed later once the task is completed.
context.update(self.state)
# the task data needs to be updated with the current state so data references can be resolved properly.
# the state will be removed later once the task is completed.
context.update(self.state)
def _user_defined_state(
self, external_methods: Optional[Dict[str, Any]] = None

View File

@ -113,7 +113,9 @@ class ServiceTaskDelegate:
message = ServiceTaskDelegate.get_message_for_status(
proxied_response.status_code
)
error = f"Received an unexpected response from the service : {message}"
error = (
f"Received an unexpected response from service {name} : {message}"
)
if "error" in parsed_response:
error += parsed_response["error"]
if json_parse_error: