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

[Transform] possible NPE in transform preview if data is empty #96781

Closed
hendrikmuhs opened this issue Jun 12, 2023 · 2 comments
Closed

[Transform] possible NPE in transform preview if data is empty #96781

hendrikmuhs opened this issue Jun 12, 2023 · 2 comments
Labels
>bug :ml/Transform Transform Team:ML Meta label for the ML team

Comments

@hendrikmuhs
Copy link
Contributor

If data is missing the composite aggregation might be null and transform preview fails with an NPE:

{
  "error": {
    "root_cause": [
      {
        "type": "null_pointer_exception",
        "reason": """Cannot invoke "org.elasticsearch.search.aggregations.bucket.composite.CompositeAggregation.getBuckets()" because "agg" is null""",
        "stack_trace": """org.elasticsearch.ElasticsearchException$1: Cannot invoke "org.elasticsearch.search.aggregations.bucket.composite.CompositeAggregation.getBuckets()" because "agg" is null
	at org.elasticsearch.server@8.7.1/org.elasticsearch.ElasticsearchException.guessRootCauses(ElasticsearchException.java:668)

caused by:

Caused by: java.lang.NullPointerException: Cannot invoke "org.elasticsearch.search.aggregations.bucket.composite.CompositeAggregation.getBuckets()" because "agg" is null
	at org.elasticsearch.xpack.transform.transforms.pivot.AggregationResultUtils.extractCompositeAggregationResults(AggregationResultUtils.java:111)
	at org.elasticsearch.xpack.transform.transforms.pivot.Pivot.extractResults(Pivot.java:142)
	at org.elasticsearch.xpack.transform.transforms.common.AbstractCompositeAggFunction.lambda$preview$0(AbstractCompositeAggFunction.java:94)
	at org.elasticsearch.server@8.7.1/org.elasticsearch.action.ActionListener$2.onResponse(ActionListener.java:167)

Fix:

Handle null at:

https://github.com/elastic/elasticsearch/blob/main/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/transforms/common/AbstractCompositeAggFunction.java#L90

@elasticsearchmachine elasticsearchmachine added the Team:ML Meta label for the ML team label Jun 12, 2023
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/ml-core (Team:ML)

@AjeetNathawat
Copy link
Contributor

AjeetNathawat commented Jun 13, 2023

hi @hendrikmuhs I have created a PR for this issue, since this looks like a straightforward null check here is the PR: #96785 . If you have any suggestions please do let me know as I'm new to open source.

@prwhelan prwhelan closed this as completed Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :ml/Transform Transform Team:ML Meta label for the ML team
Projects
None yet
Development

No branches or pull requests

4 participants