Fix NPE when creating a match-all composable index template without an inline template - #22421
Fix NPE when creating a match-all composable index template without an inline template#22421llilyy wants to merge 5 commits into
Conversation
Signed-off-by: llilyy <llilyy0215@gmail.com>
PR Reviewer Guide 🔍(Review updated until commit c579dbd)Here are some key observations to aid the review process:
|
|
Persistent review updated to latest commit c9b04de |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #22421 +/- ##
============================================
- Coverage 73.48% 73.42% -0.07%
+ Complexity 76464 76391 -73
============================================
Files 6101 6102 +1
Lines 346488 346525 +37
Branches 49871 49877 +6
============================================
- Hits 254620 254432 -188
- Misses 71599 71805 +206
- Partials 20269 20288 +19 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Persistent review updated to latest commit 94c1dc6 |
|
❌ Gradle check result for 94c1dc6: 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? |
|
Persistent review updated to latest commit e273298 |
|
❌ Gradle check result for e273298: 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? |
|
Persistent review updated to latest commit c579dbd |
|
❌ Gradle check result for c579dbd: 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? |
Description
Fixes a
NullPointerExceptionwhen creating a composable index template with a match-all pattern (*) inindex_patternsand without an inlinetemplateblock:Request#validate()checked theindex.hiddenrestriction for global templates by callingindexTemplate.template().settings()without null checks. Since thetemplateblock is optional, bothtemplate()and itssettings()can be null, which caused the NPE. With this change, theindex.hiddenvalidation only runs when an inline template with settings is actually present, so a match-all,composed_of-only template can be created.The same bug existed in Elasticsearch and was fixed in 7.10.3 (elastic/elasticsearch#67310).
Added unit tests covering a global template without an inline template and one with an inline template but null settings.
Related Issues
Resolves #22420
Check List
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.