-
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
Null completion field should not throw IAE #33268
Conversation
Hi @tony-dillon, we have found your signature in our records, but it seems like you have signed with a different e-mail than the one used in yout Git commit. Can you please add both of these e-mails into your Github profile (they can be hidden), so we can match your e-mails to your Github profile? |
Please note, I have signed the CLA and have received the document via email. I have also added the email used to make the commit to my profile. |
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.
Thanks @tony-dillon , it looks good.
I left a comment regarding the usage of the _ignored
field.
if (token == Token.VALUE_NULL) { | ||
throw new MapperParsingException("completion field [" + fieldType().name() + "] does not support null values"); | ||
} else if (token == Token.START_ARRAY) { | ||
context.addIgnoredField(fieldType.name()); |
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.
I don't think we need to add explicit null
values to the _ignored
field. It should be treated as if the field was missing.
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.
stopped adding the field to the ignored list
XContentType.JSON)); | ||
assertThat(doc.docs().size(), equalTo(1)); | ||
assertNull(doc.docs().get(0).get("completion")); | ||
assertNotNull(doc.docs().get(0).getField("_ignored")); |
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 be null
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.
now checking for assertNull
return null; | ||
} | ||
|
||
if (token == Token.START_ARRAY) { |
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.
can you restore the } else if
here for readability ?
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.
reinstated the else if
…t. restored else if. updated test to assert ignored fields is null
Hi @jimczi - thanks for taking the time to review this. I've addressed your comments, but I'm afraid that there is now an error during an integration test for the I've attached the report. The only hint I can see from the report is that there may be a JVM crash:
Would you be able to advise how I should tackle this? |
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.
Thanks @tony-dillon . The jvm crash seems unrelated to this change. I'll trigger a CI build and will merge if it passes.
test this please |
@jimczi : wow - looks like nothing worked on the |
Can you merge your branch with latest master and push ? I have no idea of what is going on but this is not due to this change. |
@jimczi merge from master done. thanks again |
test this please |
The build failed again, this time with:
Seems to be triggered by this test:
I wonder, could it be that Cheers |
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.
I left a comment in the tests, they don't use the right variable when asserting.
.array("completion", Token.VALUE_NULL, Token.VALUE_NULL) | ||
.endObject()), | ||
XContentType.JSON)); | ||
assertThat(doc.docs().size(), equalTo(1)); |
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.
it should be nullDoc
?
.endObject()), | ||
XContentType.JSON)); | ||
assertThat(doc.docs().size(), equalTo(1)); | ||
assertNull(doc.docs().get(0).get("completion")); |
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.
same here
XContentType.JSON)); | ||
assertThat(doc.docs().size(), equalTo(1)); | ||
assertNull(doc.docs().get(0).get("completion")); | ||
assertNull(doc.docs().get(0).getField("_ignored")); |
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.
and here ;)
test this please |
Ahhhhh schoolboy error! thank you! |
Pinging @elastic/es-search-aggs |
Build failed:
should the assert be changed?
|
Yes it should be |
Hi @jimczi I really appreciate your time with this, and I do always run the tests locally first which actually lead to my last comment. I run my local tests like this:
When I run the tests locally, I get this:
The standout for me is: I apologise for taking up your time on this, it's my first contribution and I'm very much just working out how this stuff works 😄 Many thanks! |
No apologies needed, I just wanted to make sure that you can test locally (which is important if you become a contributor ;) ). Regarding the failure, we need |
Local tests pass! Thank you Sir!
|
@@ -440,14 +441,25 @@ public void testFieldValueValidation() throws Exception { | |||
ParsedDocument doc = defaultMapper.parse(SourceToParse.source("test", "type1", "1", BytesReference | |||
.bytes(XContentFactory.jsonBuilder() | |||
.startObject() | |||
.array("completion", " ", "") |
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.
you changed the wrong doc ?
ParsedDocument nullDoc = defaultMapper.parse(SourceToParse.source("test", "type1", "1", BytesReference | ||
.bytes(XContentFactory.jsonBuilder() | ||
.startObject() | ||
.array("completion", Token.VALUE_NULL, Token.VALUE_NULL) |
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.
it should be .nullField("completion")
@tony-dillon you pushed the change to the wrong doc ;) |
test this please |
@@ -38,6 +38,7 @@ | |||
import org.elasticsearch.common.xcontent.XContentBuilder; | |||
import org.elasticsearch.common.xcontent.XContentFactory; | |||
import org.elasticsearch.common.xcontent.XContentType; | |||
import org.elasticsearch.common.xcontent.XContentParser.Token; |
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.
Sorry I missed that we forbid unused import in our build so this needs to be removed.
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.
already fixed :) thanks
test this please |
may I ask @jimczi - what's the recommended way to run the full suite of tests before submitting a PR?
|
Sure |
Thanks for the info. I notice that you tagged this with with That would be amazing! 😄 |
@tony-dillon the plan is to have the fix in the next patch or minor release so Can you check the failure, there's an IT test that needs to be adapted. |
test this please |
@tony-dillon, I hope you don't mind that I pushed a fix directly in your branch. The change looks good but we need a green build so I triggered a new one. |
test this please |
Of course not @jimczi ! Appreciate you taking the time to dig in and find the issue. |
Success! @jimczi |
Ignore null value on the completion field Closes #33200
Ignore null value on the completion field Closes #33200
I merged in master and 6.x and 6.4.1, thanks @tony-dillon ! |
Thank you @jimczi - you really helped a lot getting this through, and it solves a real-world problem we are having trying to add completion fields to a schema then re-indexing when there are null values present. Although the code change was small, getting to the point where I could even start to look at the issue was rather slow. To help others get started developing, I've created a Docker image, and posted an article on Discuss on how to use it. https://discuss.elastic.co/t/contributing-to-elasticsearch-using-a-docker-image/147162 This should allow anybody to get developing in minutes rather then the hours I spent trying to get the environment setup correctly. Once again, many thanks for your time and patience getting this live. Cheers! |
You're welcome @tony-dillon.
We don't disclose release dates in advance so the best that I can tell you is that it will probably be soon. |
…e-default-distribution * elastic/master: (213 commits) ML: Fix build after HLRC change Fix inner hits retrieval when stored fields are disabled (_none_) (elastic#33018) SQL: Show/desc commands now support table ids (elastic#33363) Mute testValidateFollowingIndexSettings HLRC: Add delete by query API (elastic#32782) [ML] The sort field on get records should default to the record_score (elastic#33358) [ML] Minor improvements to categorization Grok pattern creation (elastic#33353) [DOCS] fix a couple of typos (elastic#33356) Disable assemble task instead of removing it (elastic#33348) Simplify the return type of FieldMapper#parse. (elastic#32654) [ML] Delete forecast API (elastic#31134) (elastic#33218) Introduce private settings (elastic#33327) [Docs] Add search timeout caveats (elastic#33354) TESTS: Fix Race Condition in Temp Path Creation (elastic#33352) Fix from_range in search_after in changes snapshot (elastic#33335) TESTS+DISTR.: Fix testIndexCheckOnStartup Flake (elastic#33349) Null completion field should not throw IAE (elastic#33268) Adds code to help with IndicesRequestCacheIT failures (elastic#33313) Prevent NPE parsing the stop datafeed request. (elastic#33347) HLRC: Add ML get overall buckets API (elastic#33297) ...
null completion values should not throw IAE and be added to ignored fields
@jimczi would you mind taking a look at this PR please? I believe all tests run via
gradlew check
pass now.many thanks,
Tony