Fix empty _source includes array returning all fields#20808
Fix empty _source includes array returning all fields#20808zheliu2 wants to merge 10 commits intoopensearch-project:mainfrom
Conversation
PR Reviewer Guide 🔍(Review updated until commit 66a9ba0)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Latest suggestions up to 66a9ba0 Explore these optional code suggestions:
Previous suggestionsSuggestions up to commit 09e1fd2
Suggestions up to commit a71032d
Suggestions up to commit 1832da4
Suggestions up to commit 576bca2
Suggestions up to commit b97be52
|
…ject#20612) When _source includes is set to an empty array (e.g., "_source": [] or "_source": {"includes": []}), the expected behavior is to return an empty _source object {}. Previously, an empty includes array was treated the same as not setting includes at all, causing all source fields to be returned. This fix adds an includesExplicit flag to FetchSourceContext to distinguish between "no includes specified" (include everything) and "empty includes explicitly specified" (include nothing). The flag is set during XContent parsing and REST request parsing, and is propagated through wire serialization for cross-node compatibility. Signed-off-by: zheliu2 <770120041@qq.com>
db9f7d9 to
702cc79
Compare
|
Persistent review updated to latest commit 702cc79 |
|
❌ Gradle check result for 702cc79: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
Signed-off-by: zheliu2 <770120041@qq.com>
|
Persistent review updated to latest commit 6773b61 |
|
❌ Gradle check result for 6773b61: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
Signed-off-by: zheliu2 <770120041@qq.com>
|
Persistent review updated to latest commit b6ee433 |
|
❌ Gradle check result for b6ee433: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
Signed-off-by: zheliu2 <770120041@qq.com>
|
Persistent review updated to latest commit b97be52 |
|
❌ Gradle check result for b97be52: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
Signed-off-by: zheliu2 <770120041@qq.com>
Signed-off-by: zheliu2 <770120041@qq.com>
|
Persistent review updated to latest commit 576bca2 |
|
❌ Gradle check result for 576bca2: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
Signed-off-by: zheliu2 <770120041@qq.com>
|
Persistent review updated to latest commit 1832da4 |
|
❌ Gradle check result for 1832da4: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
Signed-off-by: zheliu2 <770120041@qq.com>
|
Persistent review updated to latest commit a71032d |
|
❌ Gradle check result for a71032d: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
Signed-off-by: zheliu2 <770120041@qq.com>
|
Persistent review updated to latest commit 09e1fd2 |
|
❌ Gradle check result for 09e1fd2: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
Signed-off-by: zheliu2 <770120041@qq.com>
|
Persistent review updated to latest commit 66a9ba0 |
|
❌ Gradle check result for 66a9ba0: null Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
|
Closing — CI gradle-check is consistently failing due to Jenkins infrastructure issues. Will reopen or recreate if needed. |
|
Hi @zheliu2 |
Summary
Fixes #20612
_sourceincludes is set to an empty array (e.g.,"_source": []or"_source": {"includes": []}), the expected behavior is to return an empty_source: {}. Previously, an empty includes array was treated the same as not setting includes at all, causing all source fields to be returned.includesExplicitflag toFetchSourceContextto distinguish between "no includes specified" (include everything) and "empty includes explicitly specified" (include nothing).fromXContent) and REST request parsing (parseFromRestRequest), and is propagated through wire serialization (version-gated to V_3_6_0) for cross-node compatibility.Changes
FetchSourceContext.java: AddedincludesExplicitboolean field, private 4-arg constructor, version-gated serialization, and filter logic that returns an empty map when includes is explicitly empty.FetchSourcePhase.java: UpdatedcontainsFilters()to recognize explicitly empty includes as a filter.FetchSourcePhaseTests.java: AddedtestEmptyIncludesArrayandtestEmptyIncludesWithExcludestest cases.Test plan
FetchSourcePhaseTests.testEmptyIncludesArray- verifies_source: []and_source: {"includes": []}both return empty sourceFetchSourcePhaseTests.testEmptyIncludesWithExcludes- verifies_source: {"includes": [], "excludes": ["field1"]}returns empty sourceFetchSourcePhaseTestscontinue to pass