Skip to content

Fix PPL aggregation request mutation - #12710

Open
revijay wants to merge 1 commit into
opensearch-project:mainfrom
revijay:fix/ppl-search-strategy-agg-loop-11679
Open

revijay wants to merge 1 commit into
opensearch-project:mainfrom
revijay:fix/ppl-search-strategy-agg-loop-11679

Conversation

@revijay

@revijay revijay commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Description

Fix the PPL search strategy aggregation loop to prevent request mutation and preserve aggregation results across multiple aggregation queries.

Previously, the aggregation request was reused and its nested query object was mutated for each aggregation. This could cause subsequent iterations to operate on a modified request. Additionally, aggs was reset inside the loop, causing results from previously processed aggregation keys to be overwritten.

This change:

Creates a fresh, isolated request for each aggregation query.
Preserves the original request query.
Initializes aggs once before the aggregation loop so results from all keys are retained.
Adds regression coverage for multiple aggregation queries.

Issues Resolved

Closes #11679

Screenshot

NA

Testing the changes

Targeted PPL search strategy tests:

yarn test:jest src/plugins/query_enhancements/server/search/ppl_search_strategy.test.ts

Result: 23 passed, 23 total

Also verified:

git diff --check

No whitespace errors.

The full Query Enhancements test suite was also run. It had one unrelated existing failure in:

src/plugins/query_enhancements/public/search/filters/sql_filter_utils.test.ts

The failing SQL test was reproduced independently and is unrelated to these changes.

Check List

  • All tests pass
    • yarn test:jest
    • yarn test:jest_integration
  • New functionality includes testing.
  • New functionality has been documented.
  • Commits are signed per the DCO using --signoff

Signed-off-by: revijay <reshmi.vijayan@ibm.com>
@revijay revijay changed the title Fix PPL aggregation request mutation (#11679) Fix PPL aggregation request mutation Sep 6, 2026
@github-actions

github-actions Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🧪 PR contains tests
🔒 No security concerns identified
📝 TODO sections

🔀 No multiple PR themes
⚡ No major issues detected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PPL search strategy aggregation loop mutates shared request and resets aggs on each iteration

1 participant