Skip to content
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 metdata on _msearch #35938

Merged
merged 3 commits into from Nov 27, 2018
Merged

Conversation

s1monw
Copy link
Contributor

@s1monw s1monw commented Nov 27, 2018

MultiSearchRequests issues through _msearch now validate all keys
in the metadata section. Previously unknown keys were ignored
while now an exception is thrown.

Closes #35869

MultiSearchRequests issues through `_msearch` now validate all keys
in the metadata section. Previously unknown keys were ignored
while now an exception is thrown.

Closes elastic#35869
@s1monw s1monw added >bug >breaking :Search/Search Search-related issues that do not fall into other categories v7.0.0 labels Nov 27, 2018
@s1monw s1monw requested a review from javanna November 27, 2018 09:49
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search

Copy link
Member

@javanna javanna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left a couple of small things, LGTM though.

[float]
==== Multi Search Request metadata validation

MultiSearchRequests issues through `_msearch` now validate all keys in the metadata section. Previously unknown keys were ignored
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/issues/issued?

} else {
// TODO we should not be lenient here and fail if there is any unknown key in the source map
throw new IllegalStateException("key [" + entry.getKey() + "] is not supported in the metadata section");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IllegalArgumentException ?

} else if ("allow_no_indices".equals(entry.getKey()) || "allowNoIndices".equals(entry.getKey())) {
allowNoIndices = value;
} else if ("ignore_throttled".equals(entry.getKey()) || "ignoreThrottled".equals(entry.getKey())) {
ignoreThrottled = value;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should rather improve IndicesOptions#fromMap and make sure that we don't ignore what we don't recognize? I believe we have the same problem in create and restore snapshot API. Could we make the method remove what it parses and check that the map is left empty after all the parsing? Just an idea.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is unrelated. In this case we need to know if the key is valid and fromMap doesn't tell me what it consumed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that is why I am proposing to change/improve fromMap and to make other callers of it stricter as well. It does not have to be as part of this PR but I think it would be a good change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure I understand what you mean. can you make an example?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't tried this so it may not work but I am wondering if fromMap removes what it parses from the map provided as argument, and we also update our current "parsing" code to remove the corresponding entry from the map whenever a field is parsed, we can enforce that the map needs to be empty at the end (hence making parsing strict) without having to duplicate the parsing code. Does that make sense?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>breaking >bug :Search/Search Search-related issues that do not fall into other categories v7.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants