From 73e35deab403e0d0effee80df9ed6ed7e1904d2c Mon Sep 17 00:00:00 2001 From: Akshaya Annavajhala Date: Wed, 26 Jun 2024 10:23:29 -0700 Subject: [PATCH] only serialize failure details if they exist (#707) * only serialize failure details if they exist Signed-off-by: Akshaya Annavajhala * Pin workflow SDK 0.4.1 in example (#715) * Pin workflow SDK 0.4.1 in example Signed-off-by: Bernd Verst * fix workflow dev version Signed-off-by: Bernd Verst * fix workflow example dependency Signed-off-by: Bernd Verst --------- Signed-off-by: Bernd Verst Signed-off-by: Akshaya Annavajhala --------- Signed-off-by: Akshaya Annavajhala Signed-off-by: Bernd Verst Co-authored-by: Bernd Verst --- .../dapr/ext/workflow/workflow_state.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ext/dapr-ext-workflow/dapr/ext/workflow/workflow_state.py b/ext/dapr-ext-workflow/dapr/ext/workflow/workflow_state.py index d93a3c01..10847fc5 100644 --- a/ext/dapr-ext-workflow/dapr/ext/workflow/workflow_state.py +++ b/ext/dapr-ext-workflow/dapr/ext/workflow/workflow_state.py @@ -60,7 +60,7 @@ def __str__(self) -> str: return json.dumps(self.to_json(), indent=4, sort_keys=True, default=str) def to_json(self): - return { + state_dict = { 'instance_id': self.__obj.instance_id, 'name': self.__obj.name, 'runtime_status': self.__obj.runtime_status.name, @@ -69,9 +69,11 @@ def to_json(self): 'serialized_input': self.__obj.serialized_input, 'serialized_output': self.__obj.serialized_output, 'serialized_custom_status': self.__obj.serialized_custom_status, - 'failure_details': { + } + if self.__obj.failure_details is not None: + state_dict['failure_details'] = { 'message': self.__obj.failure_details.message, 'error_type': self.__obj.failure_details.error_type, 'stack_trace': self.__obj.failure_details.stack_trace, - }, - } + } + return state_dict