From 0566ee1b7d83fb8eeda2cc1227c576418e785985 Mon Sep 17 00:00:00 2001 From: Akanksha Trehun <146705736+magic-peach@users.noreply.github.com> Date: Thu, 15 Oct 2026 15:00:25 +0000 Subject: [PATCH] Guard against a None RpcError details in DaprWorkflowClient.get_workflow_state (#1224) The async client already checks error.details() before searching it for 'no such instance exists'. The sync client does not, so any RpcError whose details() returns None, such as UNAVAILABLE when the sidecar is unreachable, crashes with a TypeError instead of surfacing the real error. Signed-off-by: Akanksha Trehun Co-authored-by: Sam Kendziora Co-authored-by: Dapr Bot <56698301+dapr-bot@users.noreply.github.com> (cherry picked from commit 9646a5789def23fbda2dcc64052c2bfa0a2b5605) Signed-off-by: dapr-bot --- dapr/ext/workflow/dapr_workflow_client.py | 2 +- tests/ext/workflow/test_workflow_client.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/dapr/ext/workflow/dapr_workflow_client.py b/dapr/ext/workflow/dapr_workflow_client.py index 96a8d9c33..975c5c292 100644 --- a/dapr/ext/workflow/dapr_workflow_client.py +++ b/dapr/ext/workflow/dapr_workflow_client.py @@ -189,7 +189,7 @@ def get_workflow_state( ) return WorkflowState(state) if state else None except RpcError as error: - if 'no such instance exists' in error.details(): + if error.details() and 'no such instance exists' in error.details(): self._logger.warning(f'Workflow instance not found: {instance_id}') return None self._logger.error( diff --git a/tests/ext/workflow/test_workflow_client.py b/tests/ext/workflow/test_workflow_client.py index c19eb6a74..10461c4b6 100644 --- a/tests/ext/workflow/test_workflow_client.py +++ b/tests/ext/workflow/test_workflow_client.py @@ -77,6 +77,8 @@ def get_orchestration_state(self, instance_id, fetch_payloads, app_id=None): return self._inner_get_orchestration_state( instance_id, client.OrchestrationStatus.PENDING ) + elif wf_status == 'no-details': + raise SimulatedRpcError(code='UNAVAILABLE', details=None) else: raise SimulatedRpcError(code='UNKNOWN', details='unknown error') @@ -274,6 +276,10 @@ def test_client_functions(self): assert actual_get_result is None + wf_status = 'no-details' + with self.assertRaises(RpcError): + wfClient.get_workflow_state(instance_id=mock_instance_id, fetch_payloads=True) + wf_status = 'found' actual_get_result = wfClient.get_workflow_state( instance_id=mock_instance_id, fetch_payloads=True