Should `ElasticsearchIndicesClient#existsIndexTemplate()` with invalid credentials return `false` or `ElasticsearchException(security_exception, 401)` #212
openjdk version "11.0.11" 2021-04-20 OpenJDK Runtime Environment AdoptOpenJDK-11.0.11+9 (build 11.0.11+9) OpenJDK 64-Bit Server VM AdoptOpenJDK-11.0.11+9 (build 11.0.11+9, mixed mode)
Elasticsearch Version
8.1.0
Problem description
ElasticsearchIndicesClient#existsIndexTemplate() with invalid credentials returns false when I expected the returned valued to be an ElasticsearchException(security_exception, 401) that would have been consistent with the returned value of methods like ElasticsearchIlmClient#getLifecycle().
Could you please clarify the expected behaviour? I expected an ElasticsearchException(security_exception, 401) and got surprised.
This is actually a bug related to the fact that this is a HEAD request that doesn't return a JSON error reponse. We have to create the error response in the client in this case.
Java API client version
8.1.0
Java version
openjdk version "11.0.11" 2021-04-20 OpenJDK Runtime Environment AdoptOpenJDK-11.0.11+9 (build 11.0.11+9) OpenJDK 64-Bit Server VM AdoptOpenJDK-11.0.11+9 (build 11.0.11+9, mixed mode)
Elasticsearch Version
8.1.0
Problem description
ElasticsearchIndicesClient#existsIndexTemplate()
with invalid credentials returnsfalse
when I expected the returned valued to be anElasticsearchException(security_exception, 401)
that would have been consistent with the returned value of methods likeElasticsearchIlmClient#getLifecycle()
.Could you please clarify the expected behaviour? I expected an
ElasticsearchException(security_exception, 401)
and got surprised.See https://github.com/jenkinsci/opentelemetry-plugin/blob/opentelemetry-2.3.0-rc1/src/main/java/io/jenkins/plugins/opentelemetry/backend/elastic/ElasticsearchLogStorageRetriever.java#L218-L243