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

[ML] find_structure_finder endpoint NPE risk with should_trim_fields #35462

Closed
droberts195 opened this issue Nov 12, 2018 · 2 comments
Closed
Assignees
Labels
>bug :ml Machine learning

Comments

@droberts195
Copy link
Contributor

The ML find_structure_finder endpoint can fail with a null pointer exception if should_trim_fields is overridden to true and there are blank fields in the delimited file.

As an example to reproduce this:

curl -s -H "Content-Type: application/json" -XPOST "localhost:9200/_xpack/ml/find_file_structure?pretty&format=delimited&explain&should_trim_fields=true" -T PAN-sample.log

where PAN-sample.log is a CSV file containing blank field values.

The output is:

{
  "error" : {
    "root_cause" : [
      {
        "type" : "null_pointer_exception",
        "reason" : null
      }
    ],
    "type" : "null_pointer_exception",
    "reason" : null
  },
  "status" : 500
}

Stack trace is:

[elasticsearch] [2018-11-12T16:29:06,517][WARN ][r.suppressed             ] [node-0] path: /_xpack/ml/find_file_structure, params: {explain=, pretty=, should_trim_fields=true, format=delimited}
[elasticsearch] java.lang.NullPointerException: null
[elasticsearch]         at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195) ~[?:?]
[elasticsearch]         at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1654) ~[?:?]
[elasticsearch]         at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) ~[?:?]
[elasticsearch]         at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) ~[?:?]
[elasticsearch]         at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913) ~[?:?]
[elasticsearch]         at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:?]
[elasticsearch]         at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578) ~[?:?]
[elasticsearch]         at org.elasticsearch.xpack.ml.filestructurefinder.DelimitedFileStructureFinder.makeDelimitedFileStructureFinder(DelimitedFileStructureFinder.java:85) ~[x-pack-ml-6.6.0-SNAPSHOT.jar:6.6.0-SNAPSHOT]
[elasticsearch]         at org.elasticsearch.xpack.ml.filestructurefinder.DelimitedFileStructureFinderFactory.createFromSample(DelimitedFileStructureFinderFactory.java:66) ~[x-pack-ml-6.6.0-SNAPSHOT.jar:6.6.0-SNAPSHOT]
[elasticsearch]         at org.elasticsearch.xpack.ml.filestructurefinder.FileStructureFinderManager.makeBestStructureFinder(FileStructureFinderManager.java:278) ~[x-pack-ml-6.6.0-SNAPSHOT.jar:6.6.0-SNAPSHOT]
[elasticsearch]         at org.elasticsearch.xpack.ml.filestructurefinder.FileStructureFinderManager.findFileStructure(FileStructureFinderManager.java:150) ~[x-pack-ml-6.6.0-SNAPSHOT.jar:6.6.0-SNAPSHOT]
[elasticsearch]         at org.elasticsearch.xpack.ml.filestructurefinder.FileStructureFinderManager.findFileStructure(FileStructureFinderManager.java:121) ~[x-pack-ml-6.6.0-SNAPSHOT.jar:6.6.0-SNAPSHOT]
[elasticsearch]         at org.elasticsearch.xpack.ml.action.TransportFindFileStructureAction.buildFileStructureResponse(TransportFindFileStructureAction.java:50) ~[x-pack-ml-6.6.0-SNAPSHOT.jar:6.6.0-SNAPSHOT]
[elasticsearch]         at org.elasticsearch.xpack.ml.action.TransportFindFileStructureAction.lambda$doExecute$0(TransportFindFileStructureAction.java:39) [x-pack-ml-6.6.0-SNAPSHOT.jar:6.6.0-SNAPSHOT]
[elasticsearch]         at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingRunnable.run(ThreadContext.java:627) [elasticsearch-6.6.0-SNAPSHOT.jar:6.6.0-SNAPSHOT]
[elasticsearch]         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
[elasticsearch]         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
[elasticsearch]         at java.lang.Thread.run(Thread.java:834) [?:?]
@droberts195 droberts195 added >bug :ml Machine learning labels Nov 12, 2018
@droberts195 droberts195 self-assigned this Nov 12, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/ml-core

@droberts195
Copy link
Contributor Author

@webmat this is the bug you reported.

droberts195 added a commit to droberts195/elasticsearch that referenced this issue Nov 12, 2018
The NPE would occur if should_trim_field was overridden to
true and any field value was completely blank.  This change
defends against this situation.

Fixes elastic#35462
droberts195 added a commit that referenced this issue Nov 13, 2018
The NPE would occur if should_trim_field was overridden to
true and any field value was completely blank.  This change
defends against this situation.

Fixes #35462
droberts195 added a commit that referenced this issue Nov 13, 2018
The NPE would occur if should_trim_field was overridden to
true and any field value was completely blank.  This change
defends against this situation.

Fixes #35462
droberts195 added a commit that referenced this issue Nov 13, 2018
The NPE would occur if should_trim_field was overridden to
true and any field value was completely blank.  This change
defends against this situation.

Fixes #35462
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :ml Machine learning
Projects
None yet
Development

No branches or pull requests

2 participants