-
Notifications
You must be signed in to change notification settings - Fork 19
Closed
Labels
Description
elasticsearch-transport gem is unable to send custom headers client.search(q: '*', size: 2, headers: {"Elastic-Api-Version"=>"2023-10-31"}) in Manticore implementation probably since 7.2.
The headers are ignored and overwritten by the initial constructor headers.
Faraday and curb do merge with input headers, hence exclude in this bug
Reproduce steps
Test it against serverless endpoint which should return 400 when the header is not "Elastic-Api-Version"=>"2023-10-31"
require "elasticsearch"
require "elasticsearch/transport/transport/http/manticore"
client = Elasticsearch::Client.new(
{
:hosts=>["https://YOUR_SERVERLESS_ENDPOINT:443"],
:transport_options=>
{
:headers=>{
"Authorization"=>"Basic YOUR_TOKEN",
"Elastic-Api-Version"=>"2023-10-31"
},
:request_timeout=>60,
:connect_timeout=>10,
:socket_timeout=>60
},
:transport_class=>Elasticsearch::Transport::Transport::HTTP::Manticore,
:ssl=>{:ssl=>true, :verify=>:default, :trust_strategy=>nil}
})
# expect 200
puts client.info
# expect 400 but get 200
puts client.search(q: '*', size: 2, headers: {"Elastic-Api-Version"=>"2024-10-31"})The last line is expected to get 400 but got 200 because the headers didn't send. You can initialize the Elasticsearch::Clientwith the wrong header "2024-10-31", the server returns 400.