From a1d444f0b2e75f8e8ab63aee09f27a67f46b9e7e Mon Sep 17 00:00:00 2001 From: vedantsahai18 Date: Tue, 15 Oct 2024 20:57:50 -0400 Subject: [PATCH] fix(agents-api): temporal error exceptions caught --- agents-api/agents_api/common/interceptors.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/agents-api/agents_api/common/interceptors.py b/agents-api/agents_api/common/interceptors.py index c6e8e2eaf..ad9ae4d29 100644 --- a/agents-api/agents_api/common/interceptors.py +++ b/agents-api/agents_api/common/interceptors.py @@ -4,6 +4,9 @@ certain types of errors that are known to be non-retryable. """ +from temporalio.workflow import ContinueAsNewError, ReadOnlyContextError, NondeterminismError +from temporalio.service import RPCError +from temporalio.exceptions import TemporalError, FailureError from typing import Optional, Type from temporalio.exceptions import ApplicationError @@ -31,6 +34,8 @@ class CustomActivityInterceptor(ActivityInboundInterceptor): async def execute_activity(self, input: ExecuteActivityInput): try: return await super().execute_activity(input) + except (ContinueAsNewError, ReadOnlyContextError, NondeterminismError, RPCError, TemporalError, FailureError): + raise except BaseException as e: if is_non_retryable_error(e): raise ApplicationError( @@ -53,6 +58,8 @@ class CustomWorkflowInterceptor(WorkflowInboundInterceptor): async def execute_workflow(self, input: ExecuteWorkflowInput): try: return await super().execute_workflow(input) + except (ContinueAsNewError, ReadOnlyContextError, NondeterminismError, RPCError, TemporalError, FailureError): + raise except BaseException as e: if is_non_retryable_error(e): raise ApplicationError(