diff --git a/azure/durable_functions/models/OrchestratorState.py b/azure/durable_functions/models/OrchestratorState.py index abf09a74..7b426292 100644 --- a/azure/durable_functions/models/OrchestratorState.py +++ b/azure/durable_functions/models/OrchestratorState.py @@ -1,5 +1,5 @@ import json -from typing import List, Any, Dict, Optional, Union +from typing import List, Any, Dict, Optional from azure.durable_functions.models.ReplaySchema import ReplaySchema diff --git a/azure/durable_functions/models/TaskOrchestrationExecutor.py b/azure/durable_functions/models/TaskOrchestrationExecutor.py index 66389935..5cfc0b5f 100644 --- a/azure/durable_functions/models/TaskOrchestrationExecutor.py +++ b/azure/durable_functions/models/TaskOrchestrationExecutor.py @@ -276,6 +276,16 @@ def get_orchestrator_state_str(self) -> str: message contains in it the string representation of the orchestration's state """ + if(self.output is not None): + try: + # Attempt to serialize the output. If serialization fails, raise an + # error indicating that the orchestration output is not serializable, + # which is not permitted in durable Python functions. + json.dumps(self.output) + except Exception as e: + self.output = None + self.exception = e + state = OrchestratorState( is_done=self.orchestration_invocation_succeeded, actions=self.context._actions,