Skip to content

Commit

Permalink
Ensure compatibility with httpx v0.28.0+
Browse files Browse the repository at this point in the history
SSL errors are thrown slightly different in httpx v0.28.0+ - Ensure
these are caught and re-raised as TlsErrors.
  • Loading branch information
carlsmedstad committed Jan 8, 2025
1 parent 4717288 commit 11e0243
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions elastic_transport/_node/_http_httpx.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,13 @@ async def perform_request( # type: ignore[override]
)
elif isinstance(e, ssl.SSLError):
err = TlsError(str(e), errors=(e,))
# Detect SSL errors for httpx v0.28.0+
elif isinstance(e, httpx.ConnectError):
context = e.__cause__.__context__
if isinstance(context, ssl.SSLError):
err = TlsError(str(context), errors=(e,))
else:
err = ConnectionError(str(e), errors=(e,))
else:
err = ConnectionError(str(e), errors=(e,))
self._log_request(
Expand Down

0 comments on commit 11e0243

Please sign in to comment.