Skip to content

Commit f220877

Browse files
committed
Ensure compatibility with httpx v0.28.0+
SSL errors are thrown slightly different in httpx v0.28.0+ - Ensure these are caught and re-raised as TlsErrors.
1 parent 4717288 commit f220877

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

elastic_transport/_node/_http_httpx.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,13 @@ async def perform_request( # type: ignore[override]
158158
)
159159
elif isinstance(e, ssl.SSLError):
160160
err = TlsError(str(e), errors=(e,))
161+
# Detect SSL errors for httpx v0.28.0+
162+
elif isinstance(e, httpx.ConnectError) and e.__cause__:
163+
context = e.__cause__.__context__
164+
if isinstance(context, ssl.SSLError):
165+
err = TlsError(str(context), errors=(e,))
166+
else:
167+
err = ConnectionError(str(e), errors=(e,))
161168
else:
162169
err = ConnectionError(str(e), errors=(e,))
163170
self._log_request(

0 commit comments

Comments
 (0)