[BUG] Delete index fails silently
Closed this issue · 1 comments
barbulescu commented
Describe the bug
Delete index failures are ignored as response from HTTP delete status is not checked.
To Reproduce
class DeleteIndexTest : SearchTestBase() {
@Test
fun deleteFailsWhenIndexIsNotAvailable() = coRun {
val indexName = randomIndexName()
val exception = shouldThrow<RestException> {
client.deleteIndex(indexName)
}
exception.status shouldBe 404
exception.message shouldContain "index_not_found_exception"
}
}
Expected behavior
HTTP status should be checked and exception thrown if it is not success.
On the ES docs the default behaviour is to fail, but this can be changed by setting ignore_unavailable
to true
.
Your context
- what versions of software are you using - 2.1.13
- what operating system are you using - 22.04.1-Ubuntu
- whatever else you think is relevant
Will you be able to help with a pull request?
Yes.
Should we check status on RestClient.doRequest
and throw RestException on failure?
jillesvangurp commented
Nice catch. There may be more places in the code where things could fail. Might be something that we can generalize with an interface and extension function perhaps?