elasticsearch-ruby
elasticsearch-ruby copied to clipboard
Elasticsearch server validation is incompatible with some builds
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:

This happens both with the MacOS homebrew version of ElasticSearch as well as the prebuilt version we run on linux on our CI.
Another datapoint - on our CI we don't get this header at all on a linux build of version 7.8.1:

Out of curiosity I tried the latest 7.17.2 linux build which does include the header but again with capitalized X:

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.
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?
The team is going to look into this.