elasticsearch-ruby icon indicating copy to clipboard operation
elasticsearch-ruby copied to clipboard

Elasticsearch server validation is incompatible with some builds

Open dbackeus opened this issue 3 years ago • 4 comments

The Elasticsearch::Client#verify_with_version_or_header method expects the ElasticSearch server to return a x-elastic-product header: https://github.com/elastic/elasticsearch-ruby/blob/main/elasticsearch/lib/elasticsearch.rb#L113

However in some builds of ElasticSearch, such as the latest homebrew version the header is returned with a capitalized X which makes the check fail and the gem unusable: image

This happens both with the MacOS homebrew version of ElasticSearch as well as the prebuilt version we run on linux on our CI.

dbackeus avatar Apr 19 '22 11:04 dbackeus

Another datapoint - on our CI we don't get this header at all on a linux build of version 7.8.1: Screenshot 2022-04-19 at 14 22 21

dbackeus avatar Apr 19 '22 12:04 dbackeus

Out of curiosity I tried the latest 7.17.2 linux build which does include the header but again with capitalized X: Screenshot 2022-04-19 at 14 29 13

dbackeus avatar Apr 19 '22 12:04 dbackeus

Hi @dbackeus, Thanks for reporting this. It looks like you're trying to use an 8.x release of the client with Elasticsearch 7.17.2. As we mention in Compatibility, clients are forward compatible. So for your case I'd suggest using version 7.17 of the client, since it will fail the validation otherwise.

The header was introduced in a newer version of 7.x (7.14 if I recall correctly), it was not present in 7.8.1.

picandocodigo avatar Apr 20 '22 09:04 picandocodigo

I see.

If so, perhaps it would make more sense for this validator to just compare the version variable extracted from the server response with the gem version and raise a humanly readable error when the Elasticsearch server version is lower than the gem version?

dbackeus avatar Apr 20 '22 09:04 dbackeus

The team is going to look into this.

picandocodigo avatar Sep 07 '22 10:09 picandocodigo