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

New header "X-Elastic-Client-Meta" introduced in 7.11.0 broke adapters #1224

Closed
tlang1991 opened this issue Feb 24, 2021 · 3 comments
Closed

Comments

@tlang1991
Copy link

tlang1991 commented Feb 24, 2021

We were able to create a Elasticsearch client with typhoeus adapter in 7.10 like so: Elasticsearch::Client.new(adapter: :typhoeus). And we didn't need to pre-load typhoeus by require 'typhoeus' in our code.

However, after upgrading to 7.11.1, our code no longer works and will cause NameError: uninitialized constant Elasticsearch::Transport::Client::Typhoeus in elasticsearch-transport-7.11.1/lib/elasticsearch/transport/client.rb:265:in meta_header_adapter

After some code tracing, I believe meta_header_adapter method has a bug. Based on the configured adapter, it tries to access a version constant...which means that it assumes the adapter has already been loaded. But prior to now, that has not been required.

We found out this issue could be mitigated by either:

  • Specifying enable_meta_header: false when creating the client
  • Pre-load the adapter byrequire 'typhoeus' in our code.

The issue can be demonstrated with the following script:

require 'bundler/inline'

gemfile :install do
  source "https://rubygems.org" do
    gem 'elasticsearch', "#{ENV['ES_VERSION']}"
  end
end

require 'elasticsearch'
raw_client = Elasticsearch::Client.new(adapter: :typhoeus)

Then if you run, the script finishes just fine.
ES_VERSION=7.10.1 ruby ./es-ruby-7.11.1-repro-script.rb

But will cause uninitialized constant Elasticsearch::Transport::Client::Typhoeus
ES_VERSION=7.11.1 ruby ./es-ruby-7.11.1-repro-script.rb

@picandocodigo
Copy link
Member

@tlang1991 thanks for reporting this! I'll work on a fix and release a 7.11.2 version as soon as possible.

picandocodigo added a commit that referenced this issue Feb 25, 2021
- Extracts meta header related code into a module
- Adds more tests for specific situations when http libraries haven't been loaded by the time the meta header methods are called

Related to #1224
picandocodigo added a commit that referenced this issue Feb 25, 2021
- Extracts meta header related code into a module
- Adds more tests for specific situations when http libraries haven't been loaded by the time the meta header methods are called

Related to #1224
picandocodigo added a commit that referenced this issue Feb 25, 2021
- Extracts meta header related code into a module
- Adds more tests for specific situations when http libraries haven't been loaded by the time the meta header methods are called

Related to #1224
picandocodigo added a commit that referenced this issue Feb 25, 2021
- Extracts meta header related code into a module
- Adds more tests for specific situations when http libraries haven't been loaded by the time the meta header methods are called

Related to #1224
picandocodigo added a commit that referenced this issue Feb 25, 2021
- Extracts meta header related code into a module
- Adds more tests for specific situations when http libraries haven't been loaded by the time the meta header methods are called

Related to #1224
picandocodigo added a commit that referenced this issue Feb 25, 2021
- Extracts meta header related code into a module
- Adds more tests for specific situations when http libraries haven't been loaded by the time the meta header methods are called

Related to #1224
picandocodigo added a commit that referenced this issue Feb 25, 2021
- Extracts meta header related code into a module
- Adds more tests for specific situations when http libraries haven't been loaded by the time the meta header methods are called

Related to #1224
picandocodigo added a commit that referenced this issue Feb 25, 2021
- Extracts meta header related code into a module
- Adds more tests for specific situations when http libraries haven't been loaded by the time the meta header methods are called

Related to #1224
@picandocodigo
Copy link
Member

@tlang1991 I've release 7.11.2 which fixes this issue. Please let me know if there's any other issues, thanks!

picandocodigo added a commit that referenced this issue Feb 25, 2021
- Extracts meta header related code into a module
- Adds more tests for specific situations when http libraries haven't been loaded by the time the meta header methods are called

Related to #1224
@tlang1991
Copy link
Author

tlang1991 commented Feb 26, 2021

From what we have seen, we believe this issue has been fixed. So closing this. Thank you for the quick fix!

picandocodigo added a commit that referenced this issue Mar 25, 2021
- Extracts meta header related code into a module
- Adds more tests for specific situations when http libraries haven't been loaded by the time the meta header methods are called

Related to #1224
picandocodigo added a commit that referenced this issue Mar 25, 2021
- Extracts meta header related code into a module
- Adds more tests for specific situations when http libraries haven't been loaded by the time the meta header methods are called

Related to #1224
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants