diff --git a/safety/auth/enrollment.py b/safety/auth/enrollment.py index c6ea14a1..47c29a25 100644 --- a/safety/auth/enrollment.py +++ b/safety/auth/enrollment.py @@ -27,7 +27,7 @@ def call_enrollment_endpoint( ) -> dict: """Public wrapper — delegates to platform_client.enroll(). - Catches transient network errors (httpx.NetworkError, httpx.TimeoutException) + Catches transient network errors (httpx.ConnectError, httpx.TimeoutException) that tenacity re-raises after retry exhaustion and wraps them in EnrollmentTransientFailure (exit code 75) so MDM orchestrators can distinguish retryable failures from permanent ones. @@ -60,7 +60,7 @@ def call_enrollment_endpoint( # Broader than @retry's types: also wraps ReadError/WriteError/CloseError # (transient, but not retried) as exit-code 75 for MDM orchestrators. # Excludes ProtocolError / UnsupportedProtocol (non-transient config bugs). - except (httpx.NetworkError, httpx.TimeoutException) as exc: + except (httpx.ConnectError, httpx.TimeoutException) as exc: raise EnrollmentTransientFailure( f"Enrollment failed after retries: {exc}" ) from exc diff --git a/safety/events/handlers/common.py b/safety/events/handlers/common.py index f65bc153..f75a3d5e 100644 --- a/safety/events/handlers/common.py +++ b/safety/events/handlers/common.py @@ -168,7 +168,7 @@ async def _build_context_data(self, obj: Optional["SafetyCLI"]) -> "EventContext stop=stop_after_attempt(3), wait=wait_exponential(multiplier=0.1, min=0.2, max=1.0), retry=retry_if_exception_type( - (httpx.NetworkError, httpx.TimeoutException, httpx.HTTPStatusError) + (httpx.ConnectError, httpx.TimeoutException, httpx.HTTPStatusError) ), before_sleep=before_sleep_log(logging.getLogger("api_client"), logging.WARNING), )