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

create_index! raises undefined method transport @ 7.2.0 #1004

Open
plainlystated opened this issue Aug 12, 2021 · 9 comments
Open

create_index! raises undefined method transport @ 7.2.0 #1004

plainlystated opened this issue Aug 12, 2021 · 9 comments

Comments

@plainlystated
Copy link

Upgrading from 7.1.1 -> 7.2.0. The Changelog mentions "Updates transport references" which sounds related but I couldn't find any further explanation.

I'm hitting this in a spec, on the line:

Edition.__elasticsearch__.create_index!(force: true)

The stack trace:

NoMethodError:
       undefined method `transport' for #<Elasticsearch::Transport::Transport::HTTP::Faraday:0x000055dd1927c0a8>
       Did you mean?  transliterate
     # /usr/local/bundle/gems/elasticsearch-model-7.2.0/lib/elasticsearch/model/indexing.rb:293:in `rescue in delete_index!'
     # /usr/local/bundle/gems/elasticsearch-model-7.2.0/lib/elasticsearch/model/indexing.rb:289:in `delete_index!'
     # /usr/local/bundle/gems/elasticsearch-model-7.2.0/lib/elasticsearch/model/indexing.rb:248:in `create_index!'
     # ./spec/lib/repo/search_spec.rb:6:in `block (2 levels) in <top (required)>'

Not sure if I'm doing something wrong or there is a bug related to a recent transport change.

@davidwessman
Copy link

I am experiencing the same bug.

For me it will only happen when I do create_index!(force: true) on an index that does not exist.

  • create_index! - works
  • create_index!(force: true) - works if index already exists.

@davidwessman
Copy link

I tried running the specs locally, in the test for the method that fails I get:

client.transport
=>
#<Elasticsearch::Transport::Client:0x00007ffc805e69b8
...

when I check in my Rails-code and run:

Document.__elasticsearch__.client
=>
#<Elasticsearch::Transport::Client:0x00007f89166235d0
...

Document.__elasticsearch__.client.transport
=>
#<Elasticsearch::Transport::Transport::HTTP::Faraday:0x00007f89166221f8
...

So it seems like the test-double for client is setup incorrectly.

@sonalkr132
Copy link

I am experiencing the same bug.

same three ✌️ .

It is related to changes introduced in this PR #999
Updating to elasticsearch 7.14 fixes this error, however now my rake db:setup is blowing up with:

NoMethodError: undefined method `tracer=' for #<Elasticsearch::Transport::Client

sonalkr132 added a commit to rubygems/rubygems.org that referenced this issue Aug 20, 2021
…sticsearch-rails-7.2.0"

This reverts commit 14469cb, reversing
changes made to 50f05ef.
Fixes: elastic/elasticsearch-rails#1004
@picandocodigo
Copy link
Member

Thanks for reporting this, I'm going to look into it and release a fix as soon as possible.

@sled
Copy link

sled commented Aug 24, 2021

Same here:

MyModel.__elasticsearch__.create_index!(force: true)

results in:

NoMethodError (undefined method `transport' for #<Elasticsearch::Transport::Transport::HTTP::Faraday:0x00007ff960ea6f08>)

the error stems from here:

https://github.com/elastic/elasticsearch-rails/blob/master/elasticsearch-model/lib/elasticsearch/model/indexing.rb#L293
https://github.com/elastic/elasticsearch-rails/blob/master/elasticsearch-model/lib/elasticsearch/model/indexing.rb#L293

the nested transport looks like a typo: client.transport.transport

If I inspect it on the rails console I get:

irb(main):014:0> MyModel.__elasticsearch__.client.transport.class
=> Elasticsearch::Transport::Transport::HTTP::Faraday

irb(main):015:0> MyModel.__elasticsearch__.client.transport.respond_to?(:transport)
=> false

@1st8
Copy link

1st8 commented Oct 7, 2021

Fixed for me after upgrading elasticsearch to 7.15.0. The fix might have been in an earlier version though.

@pdfrod
Copy link

pdfrod commented Mar 23, 2022

Any news on this? I'm still having this issue with elasticsearch-rails 7.2.1.

In the meantime, I was able to workaround it with this:

class Elasticsearch::Transport::Transport::HTTP::Faraday
  def transport
    self
  end
end

@davidwessman
Copy link

Any news on this? I'm still having this issue with elasticsearch-rails 7.2.1.

In the meantime, I was able to workaround it with this:


class Elasticsearch::Transport::Transport::HTTP::Faraday

  def transport

    self

  end

end

We realized that we cannot upgrade the client anymore after the branching and license change because we use other provider than Elasticsearch. I guess it is time to do the work to switch to Opensearch library.

@kimegede
Copy link

I'm having the same issue.
This is the workaround I'm using right now.
#1004 (comment)

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

Successfully merging a pull request may close this issue.

8 participants