Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manticore transport unable to send custom headers with perform_request #66

Closed
kaisecheng opened this issue Sep 14, 2023 · 11 comments · Fixed by #69
Closed

Manticore transport unable to send custom headers with perform_request #66

kaisecheng opened this issue Sep 14, 2023 · 11 comments · Fixed by #69
Labels
bug Something isn't working jruby/manticore

Comments

@kaisecheng
Copy link

kaisecheng commented Sep 14, 2023

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.

@kaisecheng kaisecheng added bug Something isn't working jruby/manticore labels Sep 14, 2023
@kaisecheng
Copy link
Author

/cc @picandocodigo

@picandocodigo
Copy link
Member

Hi @kaisecheng, I'll look into this and make a patch release soon. Thanks!

@kaisecheng
Copy link
Author

@picandocodigo Could you tell me approximately the delivery schedule of the patch?

@picandocodigo
Copy link
Member

@kaisecheng I'll try to get it out as soon as possible this week time permitting or early next week if not.

@picandocodigo
Copy link
Member

@kaisecheng I think I've managed to fix it. If you can test out the branch, that'd be great. If not I can merge and prepare a patch release soon.

@kaisecheng
Copy link
Author

@picandocodigo Thanks for the patch. It works as expected

@picandocodigo
Copy link
Member

@kaisecheng thanks for testing it! I'll publish a release soon 👍

@kaisecheng
Copy link
Author

@picandocodigo I'll be on PTO for three weeks. I am hoping to get a new release version of elasticsearch-transport for logstash-plugin this week before I go. It would be great if you could publish a release soon ❤️

@picandocodigo
Copy link
Member

@kaisecheng 8.2.4 is out with this fix, thanks!

@kaisecheng
Copy link
Author

@picandocodigo thanks! Is it possible to backport the fix to elasticsearch-ruby 7.17 branch? Logstash plugins are still depending on 7.17 🙇

@picandocodigo
Copy link
Member

@kaisecheng elasticsearch-ruby v7.17.9 is now available with the fix to elasticsearch-transport 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working jruby/manticore
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants