From 2ceb42dcf406a187f37ee9d51bb47f2b6213b4af Mon Sep 17 00:00:00 2001 From: Lee Hinman Date: Tue, 3 Jun 2025 16:56:10 -0600 Subject: [PATCH 1/9] Correctly ignore system indices when validationg dot-prefixed indices Prior to this change, the (incorrect) assumption was that `threadContext.isSystemContext()` returned true when dealing with system indices. This was eventually revealed to be false (though there is a separate issue where we aren't emitting deprecation warnings when running locally, but that is a separate thing). To fix this, the `DotPrefixValidator` now correctly receives a `SystemIndices` instance and uses the `findMatchingDescriptor` and `findMatchingDataStreamDescriptor` methods to determine whether a system index is being referenced. When a matching descriptor is found, the warning emission is skipped. --- modules/dot-prefix-validation/build.gradle | 2 +- .../validation/AutoCreateDotValidator.java | 5 +++-- .../validation/CreateIndexDotValidator.java | 5 +++-- .../validation/DotPrefixValidationPlugin.java | 8 +++++--- .../validation/DotPrefixValidator.java | 9 ++++++++- .../validation/IndexTemplateDotValidator.java | 5 +++-- .../validation/DotPrefixValidatorTests.java | 3 ++- .../test/dot_prefix/10_basic.yml | 19 +++++++++++++++++++ 8 files changed, 44 insertions(+), 12 deletions(-) diff --git a/modules/dot-prefix-validation/build.gradle b/modules/dot-prefix-validation/build.gradle index 657ab3478512b..42500fd913917 100644 --- a/modules/dot-prefix-validation/build.gradle +++ b/modules/dot-prefix-validation/build.gradle @@ -16,7 +16,7 @@ esplugin { restResources { restApi { - include '_common', 'indices', 'index', 'cluster', 'nodes', 'get', 'ingest', 'bulk', 'reindex' + include '_common', 'indices', 'index', 'cluster', 'nodes', 'get', 'ingest', 'bulk', 'reindex', 'async_search' } } diff --git a/modules/dot-prefix-validation/src/main/java/org/elasticsearch/validation/AutoCreateDotValidator.java b/modules/dot-prefix-validation/src/main/java/org/elasticsearch/validation/AutoCreateDotValidator.java index ec3c22620ca46..28ff6c26a8489 100644 --- a/modules/dot-prefix-validation/src/main/java/org/elasticsearch/validation/AutoCreateDotValidator.java +++ b/modules/dot-prefix-validation/src/main/java/org/elasticsearch/validation/AutoCreateDotValidator.java @@ -13,12 +13,13 @@ import org.elasticsearch.action.admin.indices.create.CreateIndexRequest; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.util.concurrent.ThreadContext; +import org.elasticsearch.indices.SystemIndices; import java.util.Set; public class AutoCreateDotValidator extends DotPrefixValidator { - public AutoCreateDotValidator(ThreadContext threadContext, ClusterService clusterService) { - super(threadContext, clusterService); + public AutoCreateDotValidator(ThreadContext threadContext, ClusterService clusterService, SystemIndices systemIndices) { + super(threadContext, clusterService, systemIndices); } @Override diff --git a/modules/dot-prefix-validation/src/main/java/org/elasticsearch/validation/CreateIndexDotValidator.java b/modules/dot-prefix-validation/src/main/java/org/elasticsearch/validation/CreateIndexDotValidator.java index f39a1d09fa07c..4902c71d66edf 100644 --- a/modules/dot-prefix-validation/src/main/java/org/elasticsearch/validation/CreateIndexDotValidator.java +++ b/modules/dot-prefix-validation/src/main/java/org/elasticsearch/validation/CreateIndexDotValidator.java @@ -13,12 +13,13 @@ import org.elasticsearch.action.admin.indices.create.TransportCreateIndexAction; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.util.concurrent.ThreadContext; +import org.elasticsearch.indices.SystemIndices; import java.util.Set; public class CreateIndexDotValidator extends DotPrefixValidator { - public CreateIndexDotValidator(ThreadContext threadContext, ClusterService clusterService) { - super(threadContext, clusterService); + public CreateIndexDotValidator(ThreadContext threadContext, ClusterService clusterService, SystemIndices systemIndices) { + super(threadContext, clusterService, systemIndices); } @Override diff --git a/modules/dot-prefix-validation/src/main/java/org/elasticsearch/validation/DotPrefixValidationPlugin.java b/modules/dot-prefix-validation/src/main/java/org/elasticsearch/validation/DotPrefixValidationPlugin.java index c462dbdcf6c40..6e63ae9c65a10 100644 --- a/modules/dot-prefix-validation/src/main/java/org/elasticsearch/validation/DotPrefixValidationPlugin.java +++ b/modules/dot-prefix-validation/src/main/java/org/elasticsearch/validation/DotPrefixValidationPlugin.java @@ -13,6 +13,7 @@ import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.util.concurrent.ThreadContext; +import org.elasticsearch.indices.SystemIndices; import org.elasticsearch.plugins.ActionPlugin; import org.elasticsearch.plugins.Plugin; @@ -30,12 +31,13 @@ public DotPrefixValidationPlugin() {} public Collection createComponents(PluginServices services) { ThreadContext context = services.threadPool().getThreadContext(); ClusterService clusterService = services.clusterService(); + SystemIndices systemIndices = services.systemIndices(); actionFilters.set( List.of( - new CreateIndexDotValidator(context, clusterService), - new AutoCreateDotValidator(context, clusterService), - new IndexTemplateDotValidator(context, clusterService) + new CreateIndexDotValidator(context, clusterService, systemIndices), + new AutoCreateDotValidator(context, clusterService, systemIndices), + new IndexTemplateDotValidator(context, clusterService, systemIndices) ) ); diff --git a/modules/dot-prefix-validation/src/main/java/org/elasticsearch/validation/DotPrefixValidator.java b/modules/dot-prefix-validation/src/main/java/org/elasticsearch/validation/DotPrefixValidator.java index 555d04e1c1a5d..20f7ce6ffa08e 100644 --- a/modules/dot-prefix-validation/src/main/java/org/elasticsearch/validation/DotPrefixValidator.java +++ b/modules/dot-prefix-validation/src/main/java/org/elasticsearch/validation/DotPrefixValidator.java @@ -21,6 +21,7 @@ import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.core.Nullable; +import org.elasticsearch.indices.SystemIndices; import org.elasticsearch.tasks.Task; import java.util.List; @@ -94,11 +95,13 @@ public abstract class DotPrefixValidator implements MappedActionFil DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(DotPrefixValidator.class); private final ThreadContext threadContext; + private final SystemIndices systemIndices; private final boolean isEnabled; private volatile Set ignoredIndexPatterns; - public DotPrefixValidator(ThreadContext threadContext, ClusterService clusterService) { + public DotPrefixValidator(ThreadContext threadContext, ClusterService clusterService, SystemIndices systemIndices) { this.threadContext = threadContext; + this.systemIndices = systemIndices; this.isEnabled = VALIDATE_DOT_PREFIXES.get(clusterService.getSettings()); this.ignoredIndexPatterns = IGNORED_INDEX_PATTERNS_SETTING.get(clusterService.getSettings()) .stream() @@ -139,6 +142,10 @@ void validateIndices(@Nullable Set indices) { if (IGNORED_INDEX_NAMES.contains(strippedName)) { return; } + if (systemIndices.findMatchingDescriptor(strippedName) != null + || systemIndices.findMatchingDataStreamDescriptor(strippedName) != null) { + return; + } if (this.ignoredIndexPatterns.stream().anyMatch(p -> p.matcher(strippedName).matches())) { return; } diff --git a/modules/dot-prefix-validation/src/main/java/org/elasticsearch/validation/IndexTemplateDotValidator.java b/modules/dot-prefix-validation/src/main/java/org/elasticsearch/validation/IndexTemplateDotValidator.java index dd9b0feeab388..ecdaa6c73ea80 100644 --- a/modules/dot-prefix-validation/src/main/java/org/elasticsearch/validation/IndexTemplateDotValidator.java +++ b/modules/dot-prefix-validation/src/main/java/org/elasticsearch/validation/IndexTemplateDotValidator.java @@ -12,14 +12,15 @@ import org.elasticsearch.action.admin.indices.template.put.TransportPutComposableIndexTemplateAction; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.util.concurrent.ThreadContext; +import org.elasticsearch.indices.SystemIndices; import java.util.Arrays; import java.util.HashSet; import java.util.Set; public class IndexTemplateDotValidator extends DotPrefixValidator { - public IndexTemplateDotValidator(ThreadContext threadContext, ClusterService clusterService) { - super(threadContext, clusterService); + public IndexTemplateDotValidator(ThreadContext threadContext, ClusterService clusterService, SystemIndices systemIndices) { + super(threadContext, clusterService, systemIndices); } @Override diff --git a/modules/dot-prefix-validation/src/test/java/org/elasticsearch/validation/DotPrefixValidatorTests.java b/modules/dot-prefix-validation/src/test/java/org/elasticsearch/validation/DotPrefixValidatorTests.java index 7bf1fb3810790..c8ac42382894a 100644 --- a/modules/dot-prefix-validation/src/test/java/org/elasticsearch/validation/DotPrefixValidatorTests.java +++ b/modules/dot-prefix-validation/src/test/java/org/elasticsearch/validation/DotPrefixValidatorTests.java @@ -15,6 +15,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.common.util.set.Sets; +import org.elasticsearch.indices.SystemIndices; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.threadpool.ThreadPool; import org.junit.BeforeClass; @@ -107,7 +108,7 @@ private void assertFails(Set indices) { private static class NonOperatorValidator extends DotPrefixValidator { private NonOperatorValidator() { - super(new ThreadContext(Settings.EMPTY), clusterService); + super(new ThreadContext(Settings.EMPTY), clusterService, new SystemIndices(List.of())); } @Override diff --git a/modules/dot-prefix-validation/src/yamlRestTest/resources/rest-api-spec/test/dot_prefix/10_basic.yml b/modules/dot-prefix-validation/src/yamlRestTest/resources/rest-api-spec/test/dot_prefix/10_basic.yml index 3ad7438b16b62..411e832718040 100644 --- a/modules/dot-prefix-validation/src/yamlRestTest/resources/rest-api-spec/test/dot_prefix/10_basic.yml +++ b/modules/dot-prefix-validation/src/yamlRestTest/resources/rest-api-spec/test/dot_prefix/10_basic.yml @@ -1,6 +1,11 @@ --- teardown: + - requires: + test_runner_features: ["allowed_warnings"] + - do: + allowed_warnings: + - "this request accesses system indices: [.async-search], but in a future major version, direct access to system indices will be prevented by default" indices.delete: index: .*,-.security-* @@ -194,3 +199,17 @@ teardown: - do: indices.delete_index_template: name: my-template2 + +--- +"System indices do not cause deprecation warnings": + - do: + index: + index: myindex + id: "1" + body: {foo: bar} + + - do: + async_search.submit: + index: myindex + keep_alive: 1m + keep_on_completion: true From 1b250e1d2bb6604a3657fd5e50c7012456bf3d58 Mon Sep 17 00:00:00 2001 From: Lee Hinman Date: Tue, 3 Jun 2025 17:02:09 -0600 Subject: [PATCH 2/9] Update docs/changelog/128868.yaml --- docs/changelog/128868.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 docs/changelog/128868.yaml diff --git a/docs/changelog/128868.yaml b/docs/changelog/128868.yaml new file mode 100644 index 0000000000000..e5fa649268027 --- /dev/null +++ b/docs/changelog/128868.yaml @@ -0,0 +1,5 @@ +pr: 128868 +summary: Correctly ignore system indices when validationg dot-prefixed indices +area: Indices APIs +type: bug +issues: [] From 4127f6de6ac1caffead8002293978766e1878275 Mon Sep 17 00:00:00 2001 From: Lee Hinman Date: Wed, 4 Jun 2025 13:21:04 -0600 Subject: [PATCH 3/9] Fix changelog typo --- docs/changelog/128868.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog/128868.yaml b/docs/changelog/128868.yaml index e5fa649268027..51477e3496f8d 100644 --- a/docs/changelog/128868.yaml +++ b/docs/changelog/128868.yaml @@ -1,5 +1,5 @@ pr: 128868 -summary: Correctly ignore system indices when validationg dot-prefixed indices +summary: Correctly ignore system indices when validating dot-prefixed indices area: Indices APIs type: bug issues: [] From a529af6773b427dae62a84fc65a080125f4e6a64 Mon Sep 17 00:00:00 2001 From: Keith Massey Date: Tue, 7 Apr 2026 11:12:49 -0500 Subject: [PATCH 4/9] Updating yaml test to create .tasks index to correctly fail without the fix --- .../test/dot_prefix/10_basic.yml | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/modules/dot-prefix-validation/src/yamlRestTest/resources/rest-api-spec/test/dot_prefix/10_basic.yml b/modules/dot-prefix-validation/src/yamlRestTest/resources/rest-api-spec/test/dot_prefix/10_basic.yml index 411e832718040..23ac6f591beae 100644 --- a/modules/dot-prefix-validation/src/yamlRestTest/resources/rest-api-spec/test/dot_prefix/10_basic.yml +++ b/modules/dot-prefix-validation/src/yamlRestTest/resources/rest-api-spec/test/dot_prefix/10_basic.yml @@ -1,13 +1,16 @@ --- teardown: - - requires: - test_runner_features: ["allowed_warnings"] - + - skip: + features: "allowed_warnings" - do: - allowed_warnings: - - "this request accesses system indices: [.async-search], but in a future major version, direct access to system indices will be prevented by default" indices.delete: index: .*,-.security-* + - do: + allowed_warnings: + - "this request accesses system indices: [.tasks], but in a future major version, direct access to system indices will be prevented by default" + indices.delete: + index: .tasks + ignore_unavailable: true --- "Index creation with a dot-prefix is deprecated unless x-elastic-product-origin set": @@ -202,14 +205,11 @@ teardown: --- "System indices do not cause deprecation warnings": - - do: - index: - index: myindex - id: "1" - body: {foo: bar} + - requires: + test_runner_features: ["allowed_warnings"] - do: - async_search.submit: - index: myindex - keep_alive: 1m - keep_on_completion: true + allowed_warnings: + - "this request accesses system indices: [.tasks], but in a future major version, direct access to system indices will be prevented by default" + indices.create: + index: .tasks From 2d2e265a10c52a23384f1695b8918fb8fa20bc2c Mon Sep 17 00:00:00 2001 From: Keith Massey Date: Tue, 7 Apr 2026 11:49:06 -0500 Subject: [PATCH 5/9] Removing async_search as a resource since it is not longer used in the test --- modules/dot-prefix-validation/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/dot-prefix-validation/build.gradle b/modules/dot-prefix-validation/build.gradle index 42500fd913917..657ab3478512b 100644 --- a/modules/dot-prefix-validation/build.gradle +++ b/modules/dot-prefix-validation/build.gradle @@ -16,7 +16,7 @@ esplugin { restResources { restApi { - include '_common', 'indices', 'index', 'cluster', 'nodes', 'get', 'ingest', 'bulk', 'reindex', 'async_search' + include '_common', 'indices', 'index', 'cluster', 'nodes', 'get', 'ingest', 'bulk', 'reindex' } } From 61e7a924874de7d49edef8d921002e52eebf5b91 Mon Sep 17 00:00:00 2001 From: Keith Massey Date: Tue, 7 Apr 2026 11:52:31 -0500 Subject: [PATCH 6/9] Using systemIndices.isSystemName for better performance --- .../java/org/elasticsearch/validation/DotPrefixValidator.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/dot-prefix-validation/src/main/java/org/elasticsearch/validation/DotPrefixValidator.java b/modules/dot-prefix-validation/src/main/java/org/elasticsearch/validation/DotPrefixValidator.java index cc3f70ca91f66..dccdc95a39be9 100644 --- a/modules/dot-prefix-validation/src/main/java/org/elasticsearch/validation/DotPrefixValidator.java +++ b/modules/dot-prefix-validation/src/main/java/org/elasticsearch/validation/DotPrefixValidator.java @@ -144,8 +144,7 @@ void validateIndices(@Nullable Set indices) { if (IGNORED_INDEX_NAMES.contains(strippedName)) { return; } - if (systemIndices.findMatchingDescriptor(strippedName) != null - || systemIndices.findMatchingDataStreamDescriptor(strippedName) != null) { + if (systemIndices.isSystemName(strippedName)) { return; } if (this.ignoredIndexPatterns.stream().anyMatch(p -> p.matcher(strippedName).matches())) { From 7b8e394b153986ac515e3cbaeb23ce4dce2490d7 Mon Sep 17 00:00:00 2001 From: Keith Massey Date: Tue, 7 Apr 2026 13:22:24 -0500 Subject: [PATCH 7/9] Using continue rather than return if we skip an index --- .../validation/DotPrefixValidator.java | 6 +++--- .../test/dot_prefix/10_basic.yml | 20 +++++++++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/modules/dot-prefix-validation/src/main/java/org/elasticsearch/validation/DotPrefixValidator.java b/modules/dot-prefix-validation/src/main/java/org/elasticsearch/validation/DotPrefixValidator.java index dccdc95a39be9..a4a1beac6007a 100644 --- a/modules/dot-prefix-validation/src/main/java/org/elasticsearch/validation/DotPrefixValidator.java +++ b/modules/dot-prefix-validation/src/main/java/org/elasticsearch/validation/DotPrefixValidator.java @@ -142,13 +142,13 @@ void validateIndices(@Nullable Set indices) { if (c == '.') { final String strippedName = stripDateMath(index); if (IGNORED_INDEX_NAMES.contains(strippedName)) { - return; + continue; } if (systemIndices.isSystemName(strippedName)) { - return; + continue; } if (this.ignoredIndexPatterns.stream().anyMatch(p -> p.matcher(strippedName).matches())) { - return; + continue; } if (isStateless) { throw new IllegalArgumentException("Index [" + index + "] name beginning with a dot (.) is not allowed"); diff --git a/modules/dot-prefix-validation/src/yamlRestTest/resources/rest-api-spec/test/dot_prefix/10_basic.yml b/modules/dot-prefix-validation/src/yamlRestTest/resources/rest-api-spec/test/dot_prefix/10_basic.yml index 23ac6f591beae..2543a379d1490 100644 --- a/modules/dot-prefix-validation/src/yamlRestTest/resources/rest-api-spec/test/dot_prefix/10_basic.yml +++ b/modules/dot-prefix-validation/src/yamlRestTest/resources/rest-api-spec/test/dot_prefix/10_basic.yml @@ -213,3 +213,23 @@ teardown: - "this request accesses system indices: [.tasks], but in a future major version, direct access to system indices will be prevented by default" indices.create: index: .tasks + +--- +"Deprecated index template with a system index and a dot prefix index pattern": + # This makes sure that we correctly log a deprecation warning for the a dot-prefixed index pattern in an index + # template, even if the template also has a system index pattern. + - requires: + test_runner_features: ["warnings", "headers", "allowed_warnings"] + + - do: + warnings: + - "Index [.data-*] name begins with a dot (.), which is deprecated, and will not be allowed in a future Elasticsearch version." + indices.put_index_template: + name: my-template + body: + index_patterns: [.tasks, .data-*] + data_stream: {} + + - do: + indices.delete_index_template: + name: my-template From 02a8a515163e507d2dc947cd964854c04f5d85fe Mon Sep 17 00:00:00 2001 From: Keith Massey Date: Tue, 7 Apr 2026 14:13:23 -0500 Subject: [PATCH 8/9] adding to the unit tests --- .../validation/DotPrefixValidatorTests.java | 57 ++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/modules/dot-prefix-validation/src/test/java/org/elasticsearch/validation/DotPrefixValidatorTests.java b/modules/dot-prefix-validation/src/test/java/org/elasticsearch/validation/DotPrefixValidatorTests.java index 1e58810fa1a21..e93e69f9cedf7 100644 --- a/modules/dot-prefix-validation/src/test/java/org/elasticsearch/validation/DotPrefixValidatorTests.java +++ b/modules/dot-prefix-validation/src/test/java/org/elasticsearch/validation/DotPrefixValidatorTests.java @@ -17,6 +17,7 @@ import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.common.util.set.Sets; import org.elasticsearch.core.Nullable; +import org.elasticsearch.indices.SystemIndexDescriptor; import org.elasticsearch.indices.SystemIndices; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.threadpool.ThreadPool; @@ -27,12 +28,14 @@ import java.util.Set; import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.equalTo; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; public class DotPrefixValidatorTests extends ESTestCase { private static ClusterService statefulClusterService; private static ClusterService statelessClusterService; + private static SystemIndices systemIndices; private final OperatorValidator statefulOpV = new OperatorValidator<>(statefulClusterService, true); private final NonOperatorValidator statefulNonOpV = new NonOperatorValidator<>(statefulClusterService, true); @@ -68,6 +71,23 @@ public static void beforeClass() { when(statelessClusterService.getClusterSettings()).thenReturn(statelessClusterSettings); when(statelessClusterService.getSettings()).thenReturn(statelessSettings); when(statelessClusterService.threadPool()).thenReturn(mock(ThreadPool.class)); + + systemIndices = new SystemIndices( + List.of( + new SystemIndices.Feature( + "test", + "test system indices", + List.of( + SystemIndexDescriptor.builder() + .setIndexPattern(".test-system-index*") + .setDescription("test system index") + .setType(SystemIndexDescriptor.Type.INTERNAL_UNMANAGED) + .setOrigin("test") + .build() + ) + ) + ) + ); } public void testValidation() { @@ -122,6 +142,16 @@ public void testValidation() { // Test pattern added to the settings assertIgnored(Set.of(".potato5")); assertIgnored(Set.of("<.potato5>")); + + // Test system indices are ignored + assertIgnored(Set.of(".test-system-index")); + assertIgnored(Set.of(".test-system-index-other")); + assertIgnored(Set.of(".test-system-index", ".test-system-index-other")); + assertIgnored(Set.of("<.test-system-index>")); + // Indices that don't match the system index pattern should still fail + assertFails(Set.of(".not-a-system-index")); + // If we have a mix of system and non-system, we still expect a warning + assertSecondIndexFails(List.of(".test-system-index", ".not-a-system-index")); } private void assertFails(Set indices) { @@ -142,6 +172,31 @@ private void assertFails(Set indices) { assertThat(error.getMessage(), containsString("name beginning with a dot (.) is not allowed")); } + /* + * This method asserts that the second index in the list is the one that triggers the warning/error. + */ + private void assertSecondIndexFails(List indices) { + assertThat(indices.size(), equalTo(2)); + /* + * This method asserts the key difference between stateful and stateless mode -- statful just logs a deprecation warning, while + * stateful throws an exception. + */ + var statefulValidator = new NonOperatorValidator<>(statefulClusterService, false); + statefulValidator.validateIndices(Set.copyOf(indices)); + assertWarnings( + "Index [" + + indices.get(1) + + "] name begins with a dot (.), which is deprecated, and will not be allowed in a future Elasticsearch version." + ); + + var statelessValidator = new NonOperatorValidator<>(statelessClusterService, false); + IllegalArgumentException error = expectThrows( + IllegalArgumentException.class, + () -> statelessValidator.validateIndices(Set.copyOf(indices)) + ); + assertThat(error.getMessage(), containsString("name beginning with a dot (.) is not allowed")); + } + private void assertIgnored(Set indices) { statefulNonOpV.validateIndices(indices); statefulOpV.validateIndices(indices); @@ -154,7 +209,7 @@ private class NonOperatorValidator extends DotPrefixValidator { private final boolean assertNoWarnings; private NonOperatorValidator(ClusterService clusterService, boolean assertNoWarnings) { - super(new ThreadContext(Settings.EMPTY), clusterService, new SystemIndices(List.of())); + super(new ThreadContext(Settings.EMPTY), clusterService, systemIndices); this.assertNoWarnings = assertNoWarnings; } From 3cea65513afaab5e147dbde70cac436d010e52fb Mon Sep 17 00:00:00 2001 From: Keith Massey Date: Wed, 8 Apr 2026 07:51:34 -0500 Subject: [PATCH 9/9] Apply suggestions from code review Co-authored-by: Iraklis Psaroudakis --- .../org/elasticsearch/validation/DotPrefixValidatorTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/dot-prefix-validation/src/test/java/org/elasticsearch/validation/DotPrefixValidatorTests.java b/modules/dot-prefix-validation/src/test/java/org/elasticsearch/validation/DotPrefixValidatorTests.java index e93e69f9cedf7..3cee5f7aa7994 100644 --- a/modules/dot-prefix-validation/src/test/java/org/elasticsearch/validation/DotPrefixValidatorTests.java +++ b/modules/dot-prefix-validation/src/test/java/org/elasticsearch/validation/DotPrefixValidatorTests.java @@ -178,8 +178,8 @@ private void assertFails(Set indices) { private void assertSecondIndexFails(List indices) { assertThat(indices.size(), equalTo(2)); /* - * This method asserts the key difference between stateful and stateless mode -- statful just logs a deprecation warning, while - * stateful throws an exception. + * This method asserts the key difference between stateful and stateless mode -- stateful just logs a deprecation warning, while + * stateless throws an exception. */ var statefulValidator = new NonOperatorValidator<>(statefulClusterService, false); statefulValidator.validateIndices(Set.copyOf(indices));