Skip to content

Commit 2faeba4

Browse files
committed
Fix for missing auth headers in sniff_callback
1 parent 74a531c commit 2faeba4

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

elasticsearch/_sync/client/_base.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18+
import base64
1819
import re
1920
import warnings
2021
from typing import (
@@ -166,13 +167,23 @@ def _sniffed_node_callback(
166167
def sniff_callback(
167168
transport: Transport, sniff_options: SniffOptions
168169
) -> List[NodeConfig]:
170+
# Dynamically resolve authentication headers based on the client's configuration.
171+
auth_headers = resolve_auth_headers(
172+
headers=None,
173+
http_auth=transport.http_auth,
174+
api_key=transport.api_key,
175+
basic_auth=transport.basic_auth,
176+
bearer_auth=transport.bearer_auth,
177+
)
178+
169179
for _ in transport.node_pool.all():
170180
try:
171181
meta, node_infos = transport.perform_request(
172182
"GET",
173183
"/_nodes/_all/http",
174184
headers={
175-
"accept": "application/vnd.elasticsearch+json; compatible-with=8"
185+
**auth_headers, # Include the resolved authentication headers
186+
"accept": "application/vnd.elasticsearch+json; compatible-with=8",
176187
},
177188
request_timeout=(
178189
sniff_options.sniff_timeout

0 commit comments

Comments
 (0)