-
Notifications
You must be signed in to change notification settings - Fork 25k
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
Elasticsearch high-level REST client doesn't send additional HTTP headers while querying for Elasticsearch version #117266
Comments
Can you elaborate on "Configure the high-level client with the mandatory HTTP headers"? Is is using There is a workaround though by setting the default headers on the low level Rest client. They can also be updated later if needed (e.g. token renewal). RestClientBuilder builder = RestClient.builder(...);
Header[] headers = new Header[] {
new BasicHeader("SomeHeader", "some-value"),
};
builder.setDefaultHeaders(headers);
// Create HLRC, do some stuff, and at some point we need to update the header
headers[0] = new BasicHeader("SomeHeader", "some-other-value");
// Some more stuff that will use the new header value Does this help? |
Pinging @elastic/clients-team (Team:Clients) |
Hi, The solution you recommended doesn't work, because the RequestOptions are passed in the execute call, but they are ignored by the internal call for version validation that is executed together with the intended call. It should include it also there, as there could be things like proxy requiring specific headers. We configured Spring Cloud Gateway in a way similar to this: server: spring: where the ValidateHeadersFilter is a Java class checking if HTTP mandatory headers are in place: |
Closing, as I understand you found a workaround. |
Hi, I found a workaround, but IMHO the bug is still there. Can you pls check or assign to other developers? Best regards |
Elasticsearch Version
Elasticsearch high-level REST client 7.17
Installed Plugins
No response
Java Version
openjdk version "17.0.13" 2024-10-15
OS Version
Linux 6.1.0-27-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.115-1 (2024-11-01) x86_64 GNU/Linux
Problem Description
If Elasticsearch high-level REST client is used in front of an API gateway, such as Spring Cloud Gateway, it sometimes needs to be configured to send custom additional HTTP headers in order to be validated by the API gateway (these headers might contain mandatory values to submit).
We discovered that the client checks the version of Elasticsearch without sending the additional headers. It anyway ignores the problem if it gets HTTP codes 401 or 403, but not if the returned code is HTTP 400.
In my humble opinion, the root cause of this error is not sending the additional headers. Can you please fix that?
Steps to Reproduce
Logs (if relevant)
No response
The text was updated successfully, but these errors were encountered: