Skip to content

Commit e684c69

Browse files
authored
Merge pull request #231 from MorpheusAIs/feature/no-retries-tee-error
fix: skip retries on non-retriable proxy router errors
2 parents bced9db + 255a187 commit e684c69

1 file changed

Lines changed: 35 additions & 7 deletions

File tree

src/services/proxy_router_service.py

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,20 @@ def get_http_status_code(self) -> int:
103103
return error_type_mapping.get(self.error_type, 500)
104104

105105

106+
# Error substrings from the proxy router that indicate permanent failures
107+
# where retrying the same request will never succeed.
108+
NON_RETRIABLE_ERROR_PATTERNS = [
109+
"llm tee verification failed",
110+
"p-node tee attestation failed"
111+
]
112+
113+
114+
def _is_non_retriable_error(response_text: str) -> bool:
115+
"""Return True if the response body contains a known non-retriable error."""
116+
text_lower = response_text.lower()
117+
return any(pattern in text_lower for pattern in NON_RETRIABLE_ERROR_PATTERNS)
118+
119+
106120

107121

108122
async def _execute_request(
@@ -214,21 +228,35 @@ async def _execute_request(
214228
error = response.text,
215229
event_type="proxy_http_error")
216230

231+
error_type = "http_error"
232+
if status_code >= 500:
233+
error_type = "server_error"
234+
elif status_code >= 400:
235+
error_type = "client_error"
236+
237+
non_retriable = _is_non_retriable_error(response.text)
238+
if non_retriable:
239+
req_logger.error(
240+
"Non-retriable error detected, skipping remaining retries",
241+
status_code=status_code,
242+
url=e.response.url,
243+
method=method,
244+
error=response.text,
245+
event_type="proxy_non_retriable_error")
246+
raise ProxyRouterServiceError(
247+
sanitize_error_message(f"HTTP {status_code}: {response.text}"),
248+
status_code=status_code,
249+
error_type=error_type
250+
)
251+
217252
if attempt == max_retries - 1:
218-
# If this was the last attempt, raise with status code info
219253
req_logger.error("Proxy router request failed after all retries",
220254
max_retries=max_retries,
221255
url=e.response.url,
222256
method=method,
223257
error=response.text,
224258
status_code=status_code,
225259
event_type="proxy_request_failed")
226-
error_type = "http_error"
227-
if status_code >= 500:
228-
error_type = "server_error"
229-
elif status_code >= 400:
230-
error_type = "client_error"
231-
232260
raise ProxyRouterServiceError(
233261
sanitize_error_message(f"HTTP {status_code}: {response.text}"),
234262
status_code=status_code,

0 commit comments

Comments
 (0)