question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[es/snapshot.create] Missing [X-Elastic-Product] header

See original GitHub issue

Elasticsearch version (bin/elasticsearch --version): 7.16.2

Plugins installed: []

JVM version (java -version):

openjdk version "11.0.13" 2021-10-19
OpenJDK Runtime Environment (build 11.0.13+8-Ubuntu-0ubuntu1.21.10)
OpenJDK 64-Bit Server VM (build 11.0.13+8-Ubuntu-0ubuntu1.21.10, mixed mode, sharing)

OS version (uname -a if on a Unix-like system):

Linux pop-os 5.15.8-76051508-generic #202112141040~1639505278~21.10~0ede46a SMP Tue Dec 14 22:38:29 U x86_64 x86_64 x86_64 GNU/Linux

Description of the problem including expected versus actual behavior:

When performing a snapshot using the new Java client, it fails due to missing X-Elastic-Product header sent by Elasticsearch.

Steps to reproduce:

Please include a minimal but complete recreation of the problem, including (e.g.) index creation, mappings, settings, query etc. The easier you make for us to reproduce it, the more likely that somebody will take the time to look at it.

  1. Create an FS repository,
  2. Create a snapshot using the new java client:
final CreateSnapshotRequest request = new CreateSnapshotRequest
  .Builder()
  .repository(repository)
  .snapshot(name)
  .waitForCompletion(waitForCompletion)
  .build();
client.create(request);

Client being used (maven dep):

<elasticsearch.version>7.16.2</elasticsearch.version>

...

      <dependency>
        <groupId>co.elastic.clients</groupId>
        <artifactId>elasticsearch-java</artifactId>
        <version>${elasticsearch.version}</version>
      </dependency>
  1. The code throws an exception.

Provide logs (if relevant):

co.elastic.clients.transport.TransportException: [es/snapshot.create] Missing [X-Elastic-Product] header. Please check that you are connecting to an Elasticsearch instance, and that any networking filters are preserving that header.

	at co.elastic.clients.transport.rest_client.RestClientTransport.checkProductHeader(RestClientTransport.java:340)
	at co.elastic.clients.transport.rest_client.RestClientTransport.getHighLevelResponse(RestClientTransport.java:250)
	at co.elastic.clients.transport.rest_client.RestClientTransport.performRequest(RestClientTransport.java:144)
	at co.elastic.clients.elasticsearch.snapshot.ElasticsearchSnapshotClient.create(ElasticsearchSnapshotClient.java:142)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:21 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
luispollocommented, Jan 21, 2022

I ran into the same exact problem with just a search call against ElasticSearch 6.8. Could you perhaps make this check configurable in the client instead of hard-coding for the snapshot case like you did in the workaround?

Otherwise, is there an older version of the client that does not perform this check that I could use?

1reaction
swallezcommented, Oct 21, 2022

@mertkinag please read the compatibiity policy: https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/introduction.html

The Elasticsearch Java client is forward compatible; meaning that the client supports communicating with greater or equal minor versions of Elasticsearch. Elasticsearch language clients are only backwards compatible with default distributions and without guarantees made.

So you cannot use the Java API client with Elasticsearch 6.x. The High Level Rest Client (version 6) works fine though.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[es/snapshot.create] Missing [X-Elastic-Product] header #74
When performing a snapshot using the new Java client, it fails due to missing X-Elastic-Product header sent by Elasticsearch. Steps to reproduce ...
Read more >
Elasticsearch version 7.14.0 | Elasticsearch Guide [7.17] | Elastic
... previously-started snapshot is still ongoing and a later snapshot is enqueued then there is a risk that some shard data may be...
Read more >
[es/search] Missing [X-Elastic-Product] header - Stack Overflow
My code is as following. // Create the low-level client RestClient restClient = RestClient.builder( new HttpHost ...
Read more >
Spring Data Elasticsearch - Reference Documentation
Use the builder to provide cluster addresses, set default HttpHeaders or enable SSL. 2, Create the RestHighLevelClient. 3, It is also possible ...
Read more >
Python Elasticsearch Client - Read the Docs
If your application is long-running consider turning on Sniffing to make sure the client is up to date on the cluster location. By...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found