-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
[BUG] Parsing a GetResult returns NPE if "found" field is missing #14519
Comments
Hi @dbwiddis |
Go for it, @imvtsl ! Let us know if you need any help! |
Thank you!! Appreciate it. |
I created a PR with fix. I added a unit test with this scenario. I also updated CHANGELOG.md. |
How do we go about from here? |
We normally have two maintainers review the PR. The workflows allow one maintainer's review after the last push (which I have given), but there's no great rush on this one as we're several weeks away from a release. There's also a need for the gradle checks to all pass. Often there are failures on flaky tests that are not associated with your PR, and sometimes we just have to retry those tests until they pass. There's not much you can do for the retries here; as a first-time committer any changes you make require approval to run the tests (otherwise a git amend/force-push can retrigger it) so you're sort of at the mercy of the maintainers. Not to worry, I'm checking on this PR regularly to get it through. It just may take a bit. :)
TLDR: There's nothing you need to do. The We can also backport to the 1.x branch if needed as we are still doing patch releases there. However, since this is not a user-facing issue, and mostly a developer debugging annoyance (I say as someone who spent about an hour debugging to find this corner case when writing relative code) it's really not needed on 1.3.x (our maintenance branch for the 1.x series).
I don't think so! I've approved your PR with no more comments. You did a fantastic job and I really appreciate you contributing to this project! I'm just waiting for a second maintainer to have eyes on it. They'll likely either approve and merge or maybe find some suggestion I missed in which case you might need another tweak. If nobody else looks at it after a week or so, I'll just merge it (and the auto-generated backport). Thanks again for your contribution! |
Thank you for taking out time for the detailed response. |
Not sure if that's really standard; the official limit is 1. I think the section on reviews is probably fine as-is. My hesitation in merging this with just my review is that so far I'm the only maintainer with eyes-on this from start to finish. I both created the issue and approved the PR so the number of people who even know about this is pretty small. I'd go fater if a release were imminent but we have a few weeks for that so there simply isn't a rush. I really appreciate your eagerness to get it merged, but it won't make it out until 2.16.0 anyway. I really appreciate your eagerness to contribute, though! I know many other large projects (most ASF projects) use a 72-hour rule to make sure enough people have an idea to see/contribute to things, so I'll probably wait one more day.
We have quite a few issues, many tagged good first issue, some slightly more challenging but still accessible. Is there a particular area of the codebase you're interested in working on? |
Once again, I appreciate your prompt and detailed response.
It makes sense to wait to give others a chance to see the commit. Perhaps, I came across as too eager to merge. It's my first meaningful open source contribution and I wanted to see it through!!
I did have a look at few issues tagged 'good first issue'. A lot of them seem to already have commits waiting to be merged.
I started very recently with this repo so there's nothing in particular yet. Hopefully I have something in the near future. I am going through onboarding.md. |
Describe the bug
GetResult.fromXContent(XcontentParser parser)
throws aNullPointerException
if the field "found" is missing.This is an unexpected exception type for a parsing failure and can be confusing to developers. Other missing fields throw a
ParsingException
which developers are used to handling.Related component
Libraries
To Reproduce
Run the following program.
Output:
Expected behavior
Code should either throw a
ParsingException
for a missingfound
field, or assume a sensible default (false
) if it's omitted.Additional Details
Additional context
The root cause of the problem is that
found
is initialized to null here:OpenSearch/server/src/main/java/org/opensearch/index/get/GetResult.java
Line 354 in 47feca7
And then only conditionally initialized:
OpenSearch/server/src/main/java/org/opensearch/index/get/GetResult.java
Lines 372 to 374 in 47feca7
This value is passed to the
GetResult
constructor which expects a primitiveboolean
for theexists
parameter. Unboxing the nullBoolean
results in the NPE.Suggested Fix
Option 1: test the value for null before calling the
GetResult
constructor, and throw aParsingException
.Option 2: initialize
found
tofalse
The text was updated successfully, but these errors were encountered: