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

Return null for aggregations factory even if empty aggs is present in search source #8206

Merged
merged 2 commits into from
Jun 22, 2023

Conversation

jed326
Copy link
Collaborator

@jed326 jed326 commented Jun 21, 2023

Description

Whenever "aggs" is passed into the request body, even if it is empty (ex. "aggs": {},), then this line will evaluate to true:

this.hasAggs = source != null && source.aggregations() != null;

Causing us to go down the wrong path and hit the NPE.

This behavior exists from before #7514 and was handled by various checks for the aggregators, for example like here: https://github.com/opensearch-project/OpenSearch/blob/2.8/server/src/main/java/org/opensearch/search/aggregations/AggregationPhase.java#L68-L74 where collectors are not added if the aggregators length is not 0.

Related Issues

Resolves #8115

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed per the DCO using --signoff
  • Commit changes are listed out in CHANGELOG.md file (See: Changelog)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

  • RESULT: UNSTABLE ❕
  • TEST FAILURES:
      1 org.opensearch.indices.replication.SegmentReplicationIT.testReplicationPostDeleteAndForceMerge

@codecov
Copy link

codecov bot commented Jun 21, 2023

Codecov Report

Merging #8206 (121df44) into main (68c1c86) will increase coverage by 0.01%.
The diff coverage is 0.00%.

❗ Current head 121df44 differs from pull request most recent head e97ed89. Consider uploading reports for the commit e97ed89 to get more accurate results

@@             Coverage Diff              @@
##               main    #8206      +/-   ##
============================================
+ Coverage     70.93%   70.95%   +0.01%     
- Complexity    56636    56668      +32     
============================================
  Files          4719     4719              
  Lines        267559   267559              
  Branches      39206    39207       +1     
============================================
+ Hits         189805   189850      +45     
- Misses        61714    61731      +17     
+ Partials      16040    15978      -62     
Impacted Files Coverage Δ
...earch/search/aggregations/AggregatorFactories.java 75.09% <0.00%> (-0.39%) ⬇️

... and 475 files with indirect coverage changes

… search source

Signed-off-by: Jay Deng <jayd0104@gmail.com>
@jed326
Copy link
Collaborator Author

jed326 commented Jun 22, 2023

@andrross @reta Fixed the changelog and moved the test to a new file with a basic hits.total match. Let me know what you think!

@jed326
Copy link
Collaborator Author

jed326 commented Jun 22, 2023

Flakey test from here is due to the change needing to be backported to 2.x as well.
From logs https://build.ci.opensearch.org/job/gradle-check/18133/consoleText we can see that this test was for 2.9 which we would expect to fail at this point.

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@jed326
Copy link
Collaborator Author

jed326 commented Jun 22, 2023

The test failures seem unrelated to these changes. @reta @andrross do you think we could get this merged tonight to unblock OpenSearch Dashboards builds?

wbeckler
wbeckler previously approved these changes Jun 22, 2023
Copy link

@wbeckler wbeckler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice way to add a test. Thank you for getting this in. I hope it gets approved ASAP.

@wbeckler wbeckler dismissed their stale review June 22, 2023 03:41

I do not have approval rights on this repo, even though I am an Admin and accidentally approved it.

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

  • RESULT: UNSTABLE ❕
  • TEST FAILURES:
      1 org.opensearch.cluster.allocation.AwarenessAllocationIT.testThreeZoneOneReplicaWithForceZoneValueAndLoadAwareness

…regation/60_empty.yml

Co-authored-by: Andriy Redko <drreta@gmail.com>
Signed-off-by: Jay Deng <jayd0104@gmail.com>
@jed326
Copy link
Collaborator Author

jed326 commented Jun 22, 2023

@reta Applied your suggestion, I think we're good to merge then? Thanks!

@reta reta added the backport 2.x Backport to 2.x branch label Jun 22, 2023
@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

  • RESULT: UNSTABLE ❕
  • TEST FAILURES:
      2 org.opensearch.cluster.service.MasterServiceTests.classMethod
      1 org.opensearch.search.backpressure.SearchBackpressureIT.testSearchShardTaskCancellationWithHighCpu
      1 org.opensearch.cluster.service.MasterServiceTests.testThrottlingForMultipleTaskTypes

@reta reta merged commit 049129c into opensearch-project:main Jun 22, 2023
opensearch-trigger-bot bot pushed a commit that referenced this pull request Jun 22, 2023
… search source (#8206)

* Return null for aggregations factory even if empty aggs is present in search source

Signed-off-by: Jay Deng <jayd0104@gmail.com>

* Update rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/60_empty.yml

Co-authored-by: Andriy Redko <drreta@gmail.com>
Signed-off-by: Jay Deng <jayd0104@gmail.com>

---------

Signed-off-by: Jay Deng <jayd0104@gmail.com>
Co-authored-by: Andriy Redko <drreta@gmail.com>
(cherry picked from commit 049129c)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
andrross pushed a commit that referenced this pull request Jun 22, 2023
… search source (#8206) (#8222)

* Return null for aggregations factory even if empty aggs is present in search source



* Update rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/60_empty.yml




---------



(cherry picked from commit 049129c)

Signed-off-by: Jay Deng <jayd0104@gmail.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Andriy Redko <drreta@gmail.com>
gaiksaya pushed a commit to gaiksaya/OpenSearch that referenced this pull request Jun 26, 2023
… search source (opensearch-project#8206) (opensearch-project#8222)

* Return null for aggregations factory even if empty aggs is present in search source



* Update rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/60_empty.yml




---------



(cherry picked from commit 049129c)

Signed-off-by: Jay Deng <jayd0104@gmail.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Andriy Redko <drreta@gmail.com>
imRishN pushed a commit to imRishN/OpenSearch that referenced this pull request Jun 27, 2023
… search source (opensearch-project#8206)

* Return null for aggregations factory even if empty aggs is present in search source

Signed-off-by: Jay Deng <jayd0104@gmail.com>

* Update rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/60_empty.yml

Co-authored-by: Andriy Redko <drreta@gmail.com>
Signed-off-by: Jay Deng <jayd0104@gmail.com>

---------

Signed-off-by: Jay Deng <jayd0104@gmail.com>
Co-authored-by: Andriy Redko <drreta@gmail.com>
Signed-off-by: Rishab Nahata <rnnahata@amazon.com>
sudarshan-baliga pushed a commit to Gaurav614/OpenSearch that referenced this pull request Jun 29, 2023
… search source (opensearch-project#8206)

* Return null for aggregations factory even if empty aggs is present in search source

Signed-off-by: Jay Deng <jayd0104@gmail.com>

* Update rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/60_empty.yml

Co-authored-by: Andriy Redko <drreta@gmail.com>
Signed-off-by: Jay Deng <jayd0104@gmail.com>

---------

Signed-off-by: Jay Deng <jayd0104@gmail.com>
Co-authored-by: Andriy Redko <drreta@gmail.com>
shiv0408 pushed a commit to Gaurav614/OpenSearch that referenced this pull request Apr 25, 2024
… search source (opensearch-project#8206)

* Return null for aggregations factory even if empty aggs is present in search source

Signed-off-by: Jay Deng <jayd0104@gmail.com>

* Update rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/60_empty.yml

Co-authored-by: Andriy Redko <drreta@gmail.com>
Signed-off-by: Jay Deng <jayd0104@gmail.com>

---------

Signed-off-by: Jay Deng <jayd0104@gmail.com>
Co-authored-by: Andriy Redko <drreta@gmail.com>
Signed-off-by: Shivansh Arora <hishiv@amazon.com>
@jed326 jed326 deleted the aggs-bugfix branch August 7, 2024 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x Backport to 2.x branch skip-changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Opensearch Dashboards getting 500 internal server error while fetching search aggregation data
6 participants