-
Notifications
You must be signed in to change notification settings - Fork 24.6k
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
Early validation of index requests for bulk request #12038
Conversation
Thx @jprante . It feels more inline with the rest of the code to do these things in BulkRequest#validateRequest . Maybe something there this missing (ala a null pointer check)? |
@bleskes it seems that BulkRequest#validate() is never used in the current code. |
It should be called by TransportAction#execute(Request, org.elasticsearch.action.ActionListener) . I wonder how you tested? |
The tests are very simple. NPEs can happen before TransportAction#execute. ES 1.6 examples how to trigger NPE:
That is why early validation is needed to reject invalid IndexRequests from being added to a BulkRequest. |
Hi @jprante, sorry that the feedback took a while. I've checked your examples against the latest master and the only case that is causing trouble (i.e. NPEs) now is: I agree that it is a programmer error if a Do want to give it a shot? |
Hi @jprante is there still interest in working on this PR? |
With this commit we add a precondition check to BulkRequest so we fail early if users pass `null` for the request object. For a more detailed discussion, see elastic#12038. This supersedes elastic#12038. Relates elastic#12038.
I have now created a new PR #18347 that implements the necessary not-null precondition checks and I am closing this PR in favor of the new one. |
In the Java API for adding index requests to a bulk request, the index requests are not validated immediately. This can lead to unexpected NullPointerExceptions when the source is examined.
This pull request adds early validation. It helps to detect bogus index requests before they are sent to the cluster in bulk.
Also, some bulk request test cases are included to check successful validation.