Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
HEAD /index/_alias/ always returns 200 OK even alias is not set #24644
Elasticsearch version: 5.4.0
Plugins installed: 
JVM version: java version "1.8.0_131"
OS version: Debian 3.16.39-1+deb8u2
Description of the problem including expected versus actual behavior:
Making a HEAD request on an existing index to check the existance of a given alias always returns 200 OK, even if the alias doesn't exist (for that index).
I expect a 404 status like in previous versions of ES.
Steps to reproduce:
We aligned the HEAD and GET methods (as per the HTTP specification). The problem here is that it appears that GET does not return a 404 on a non-existing alias, instead it returns an empty body. I think the reason for this is in case you specify multiple indices (
With indices, you would be able to control how to treat unavailable indices through the
Unrelated, but I would prefer to have get alias return something that indicates more clearly that the index exists but the alias doesn't, like:
rather than completely skipping the index object in the response and returning an empty body. But that is a different concern and doesn't address this issue.
It is hard to know the right thing to do here. I think the problem comes down to the API itself. The
On top of that, aligning the GET and HEAD behaviours doesn't make much sense here either as they're asking for different things. The HEAD request in our API is defined as "does this alias exist on this index?".
The only way I can think to make these two consistent is to throw a 404 if any of the listed aliases doesn't exist. Maybe that's OK. It's not terribly useful for GET, but it is useful for HEAD. Of course, this would be a breaking change
I think this should be mentioned in the Breaking changes in 5.4 document and/or fixed, because
Also the official python client doesn't know how to handle new behaviour (see the
People should know where to look. I've spent almost whole day on debugging. I thought it was an error in my application.
Hi @jasontedor. Yes, it fixes specification, but introduces incompatibility with 5.3 and older versions. See the demo below.
Steps to compare/reproduce
I compare the behaviour of ES 5.3.3 and 5.4.1 using the official Docker images.
Check an alias. Index doesn't exist.
Response. Both 5.3.3 and 5.4.1 return