-
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
Fail _search request with trailing tokens #29428
Conversation
This change validates that the `_search` request does not have trailing tokens after the main object and fails the request with a parsing exception otherwise. Closes elastic#28995
Pinging @elastic/es-search-aggs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Let's turn the error into a deprecation log on 6.x?
@@ -951,12 +951,18 @@ private SearchSourceBuilder shallowCopy(QueryBuilder queryBuilder, QueryBuilder | |||
return rewrittenBuilder; | |||
} | |||
|
|||
public void parseXContent(XContentParser parser) throws IOException { | |||
parseXContent(parser, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this default not be the other way around (pass in true by default)? The only time I think we should allow trailing tokens is in the _msearch API which is a special case. It seems safer to me to check and error on trailing tokens in the default case and then have the _msearch API use the more specialised method below? or is there something I am missing here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. I pushed c6a113b to change the default
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks @jpountz @colings86 |
This change removes the check for extra tokens when parsing a source generated by a templated _msearch request. This was added unintentionally in #29428 but the intent of this modification was to validate simple _search request only.
This change validates that the _search request does not have trailing tokens after the main object and prints a deprecation message otherwise. Relates #29428
This change validates that the
_search
request does not have trailingtokens after the main object and fails the request with a parsing exception otherwise.
Closes #28995