-
Notifications
You must be signed in to change notification settings - Fork 25.1k
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
Validate API with empty query returns HTTP code 400 instead of 200 and "valid": false #33095
Comments
I tried this out on master, it's still a bug but with a different error, instead, no response is sent (the connection is just closed) and we fail to send the error message:
|
Pinging @elastic/es-search-aggs |
Besides the missing response above which is pretty bad, I would say at first glance that it's ok for the validate query API to require a query to be provided. Looking at the code though, I see that the request has a match_all default, which sounds like maybe something has changed at some point in the REST layer where we end up setting null to the request while we should leave the default that is already set to the request? Maybe just speculating but these are my findings from looking at it for a couple of minutes. |
@dakrone @javanna First of all, thank you for such a quick response. @javanna Provided request body contains a field named "query", and its content is even a valid JSON (though it is empty), and my need is to find out if this JSON contains a valid query. Emptiness is not. I think this is enough and ES should respond with UPD: BTW even if there is no query in a request ES returns 200 as it is normal for validate API.
|
I've opened a pull request to fix this issue, see #33573. |
I did some more digging and this has been fixed in 6.x. I can only reproduce the issue on 5.6 and that's due to this line which was later changed to better handle empty queries. In this specific case we now throw error rather than returning null, which is then caught and gets converted into an OK response with flag valid set to false. I do not know if we plan to get another 5.6.x release out but I would not see this as a blocker that would be included in it anyways. @dakrone I checked against master as well and I cannot repro what you mentioned (the missing response), could you check that again please? I would be leaning towards closing this issue but I would like to first clarify that bit too. |
Thank you @javanna, I'll update my pull request with your comments. |
hi @cbismuth as I said in the PR I am not sure that the PR is needed, given that the issue has already been fixed in 6.x and master. Do you see what I mean? |
Yes @javanna, I see. I wanted to contribute a non-regression test if none was already present for the reported issue. Let me know if it's useful or not, no worry at all. |
Contributing a unit test for this sounds good @cbismuth , thanks! |
I've created a cURL recreation Bash script, see Gist here. Here is the output on
As @javanna said, issue has been fixed. I'll dig into the source code to check if REST test cases have been developed to validate empty and malformed queries. |
Elasticsearch 5.6.10.
Request
Results in:
But it should return 200 and just say this query is not valid, e. g.
Results in:
Please fix it also in 5.6.x as we currently cannot easily upgrade to 6.x.
The text was updated successfully, but these errors were encountered: