You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR adds support for passing a custom authentication class to the httpx client (#2933) with minimal changes. It is heavily inspired by the existing implementation for the requests client. Internally, it uses the already existing requests_session_auth parameter.
This mirrors the requests pattern but the variable name is semantically wrong. More critically, look at what happens downstream: if requests_session_auth was already set by the requests block above, this overwrites it. And if the consuming code only checks requests_session_auth to pass it to requests-specific node config, the httpx auth value may be silently ignored or misrouted. There should be a separate httpx_session_auth variable (or equivalent) that gets passed to the httpx node config path.
Unused import
In _async/client/utils.py:
fromtypingimport (
TYPE_CHECKING,
Any,
)
TYPE_CHECKING is imported but never used.
elastic_transport import may not be available
fromelastic_transportimportHttpxAsyncHttpNode
If httpx is not installed, HttpxAsyncHttpNode may not be importable from elastic_transport (depending on how elastic_transport handles optional dependencies). This could cause an ImportError at module import time rather than at call time. The is_httpx_http_auth function correctly wraps its import in a try/except, but is_httpx_node_class does not — it imports HttpxAsyncHttpNode unconditionally at module level.
is_httpx_node_class logic gap
The string "httpxasync" is hardcoded. If elastic_transport ever changes the alias, this silently breaks. Minor, but worth a comment referencing where that string is defined.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds support for passing a custom authentication class to the
httpxclient (#2933) with minimal changes. It is heavily inspired by the existing implementation for therequestsclient. Internally, it uses the already existingrequests_session_authparameter.See the corresponding PR in elasticsearch-py : elastic/elastic-transport-python#244