### Elasticsearch Version

8.2.0

### Installed Plugins

_No response_

### Java Version

_bundled_

### OS Version

Darwin Kernel Version 20.6.0

### Problem Description

The [simulate index API](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-simulate-index.html) returns an error if used with an index name that already exists and the existing index has an alias defined.
```
{
  "error" : {
    "root_cause" : [
      {
        "type" : "illegal_state_exception",
        "reason" : "Cannot remove non-existent alias [my-index-alias] for index [my-index]"
      }
    ],
    "type" : "illegal_state_exception",
    "reason" : "Cannot remove non-existent alias [my-index-alias] for index [my-index]"
  },
  "status" : 500
}
```

Previously in 8.0 the simulate index API would return the expected mappings, settings, and aliases even when used with an index name that already exists.

### Steps to Reproduce

1. Create a minimal index template that includes an alias
```
POST _index_template/my_template
{
  "index_patterns": [
    "my-index*"
  ],
  "template": {
    "aliases": {
      "my-index-alias": {
        "is_write_index": false
      }
    }
  }
}
```
2. Create an index using the index template
```
PUT my-index
```
3. Simulate an index with the same name as the created index
```
POST _index_template/_simulate_index/my-index
```

### Logs (if relevant)

```
info [r.suppressed] [Marshalls-MacBook-Pro.local] path: /_index_template/_simulate_index/my-index, params: {pretty=true, name=my-index}
   │      java.lang.IllegalStateException: Cannot remove non-existent alias [my-index-alias] for index [my-index]
   │      	at org.elasticsearch.cluster.metadata.Metadata$Builder.removeAlias(Metadata.java:1362) ~[elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.cluster.metadata.Metadata$Builder.updateAliases(Metadata.java:1333) ~[elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.cluster.metadata.Metadata$Builder.put(Metadata.java:1235) ~[elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.action.admin.indices.template.post.TransportSimulateIndexTemplateAction.resolveTemporaryState(TransportSimulateIndexTemplateAction.java:179) ~[elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.action.admin.indices.template.post.TransportSimulateIndexTemplateAction.masterOperation(TransportSimulateIndexTemplateAction.java:131) ~[elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.action.admin.indices.template.post.TransportSimulateIndexTemplateAction.masterOperation(TransportSimulateIndexTemplateAction.java:57) ~[elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.action.support.master.TransportMasterNodeAction.executeMasterOperation(TransportMasterNodeAction.java:121) ~[elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.action.support.master.TransportMasterNodeAction$AsyncSingleAction.lambda$doStart$3(TransportMasterNodeAction.java:215) ~[elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.action.ActionRunnable$2.doRun(ActionRunnable.java:62) ~[elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:26) [elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.common.util.concurrent.EsExecutors$DirectExecutorService.execute(EsExecutors.java:221) [elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.action.support.master.TransportMasterNodeAction$AsyncSingleAction.doStart(TransportMasterNodeAction.java:215) [elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.action.support.master.TransportMasterNodeAction.doExecute(TransportMasterNodeAction.java:152) [elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.action.support.master.TransportMasterNodeAction.doExecute(TransportMasterNodeAction.java:52) [elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.action.support.TransportAction$RequestFilterChain.proceed(TransportAction.java:79) [elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.action.support.ActionFilter$Simple.apply(ActionFilter.java:53) [elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.action.support.TransportAction$RequestFilterChain.proceed(TransportAction.java:77) [elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.security.action.filter.SecurityActionFilter.lambda$applyInternal$3(SecurityActionFilter.java:162) [x-pack-security-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.action.ActionListener$DelegatingFailureActionListener.onResponse(ActionListener.java:219) [elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.security.authz.AuthorizationService.lambda$authorizeAction$4(AuthorizationService.java:392) [x-pack-security-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.security.authz.AuthorizationService$AuthorizationResultListener.onResponse(AuthorizationService.java:958) [x-pack-security-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.security.authz.AuthorizationService$AuthorizationResultListener.onResponse(AuthorizationService.java:922) [x-pack-security-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.action.support.ContextPreservingActionListener.onResponse(ContextPreservingActionListener.java:31) [elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.security.authz.AuthorizationService.lambda$authorizeAction$5(AuthorizationService.java:406) [x-pack-security-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.action.ActionListener$1.onResponse(ActionListener.java:136) [elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.security.authz.RBACEngine.authorizeClusterAction(RBACEngine.java:165) [x-pack-security-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.security.authz.AuthorizationService.authorizeAction(AuthorizationService.java:396) [x-pack-security-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.security.authz.AuthorizationService.maybeAuthorizeRunAs(AuthorizationService.java:372) [x-pack-security-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.security.authz.AuthorizationService.lambda$authorize$1(AuthorizationService.java:257) [x-pack-security-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.action.ActionListener$1.onResponse(ActionListener.java:136) [elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.action.support.ContextPreservingActionListener.onResponse(ContextPreservingActionListener.java:31) [elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.security.authz.RBACEngine.lambda$resolveAuthorizationInfo$0(RBACEngine.java:138) [x-pack-security-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.action.ActionListener$1.onResponse(ActionListener.java:136) [elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.security.authz.store.CompositeRolesStore.lambda$getRoles$1(CompositeRolesStore.java:184) [x-pack-security-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.action.ActionListener$1.onResponse(ActionListener.java:136) [elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.core.security.authz.store.RoleReferenceIntersection.lambda$buildRole$0(RoleReferenceIntersection.java:47) [x-pack-core-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.action.ActionListener$1.onResponse(ActionListener.java:136) [elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.action.support.GroupedActionListener.onResponse(GroupedActionListener.java:55) [elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.security.authz.store.CompositeRolesStore.buildRoleFromRoleReference(CompositeRolesStore.java:232) [x-pack-security-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.core.security.authz.store.RoleReferenceIntersection.lambda$buildRole$1(RoleReferenceIntersection.java:50) [x-pack-core-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at java.lang.Iterable.forEach(Iterable.java:75) [?:?]
   │      	at org.elasticsearch.xpack.core.security.authz.store.RoleReferenceIntersection.buildRole(RoleReferenceIntersection.java:50) [x-pack-core-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.security.authz.store.CompositeRolesStore.getRole(CompositeRolesStore.java:199) [x-pack-security-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.security.authz.store.CompositeRolesStore.getRoles(CompositeRolesStore.java:174) [x-pack-security-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.security.authz.RBACEngine.resolveAuthorizationInfo(RBACEngine.java:135) [x-pack-security-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.security.authz.AuthorizationService.authorize(AuthorizationService.java:259) [x-pack-security-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.security.action.filter.SecurityActionFilter.lambda$applyInternal$4(SecurityActionFilter.java:158) [x-pack-security-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.action.ActionListener$1.onResponse(ActionListener.java:136) [elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.action.ActionListener$MappedActionListener.onResponse(ActionListener.java:101) [elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.security.authc.AuthenticatorChain.authenti
   │ info cateAsync(AuthenticatorChain.java:92) [x-pack-security-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.security.authc.AuthenticationService.authenticate(AuthenticationService.java:171) [x-pack-security-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.security.action.filter.SecurityActionFilter.applyInternal(SecurityActionFilter.java:154) [x-pack-security-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.security.action.filter.SecurityActionFilter.apply(SecurityActionFilter.java:113) [x-pack-security-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.action.support.TransportAction$RequestFilterChain.proceed(TransportAction.java:77) [elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.action.support.TransportAction.execute(TransportAction.java:54) [elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.tasks.TaskManager.registerAndExecute(TaskManager.java:170) [elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.client.internal.node.NodeClient.executeLocally(NodeClient.java:113) [elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.client.internal.node.NodeClient.doExecute(NodeClient.java:91) [elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.client.internal.support.AbstractClient.execute(AbstractClient.java:380) [elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.rest.action.admin.indices.RestSimulateIndexTemplateAction.lambda$prepareRequest$0(RestSimulateIndexTemplateAction.java:54) [elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.rest.BaseRestHandler.handleRequest(BaseRestHandler.java:103) [elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.security.rest.SecurityRestFilter.lambda$handleRequest$0(SecurityRestFilter.java:112) [x-pack-security-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.action.ActionListener$1.onResponse(ActionListener.java:136) [elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.security.authc.support.SecondaryAuthenticator.lambda$authenticateAndAttachToContext$2(SecondaryAuthenticator.java:84) [x-pack-security-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.action.ActionListener$1.onResponse(ActionListener.java:136) [elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.security.authc.support.SecondaryAuthenticator.authenticate(SecondaryAuthenticator.java:94) [x-pack-security-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.security.authc.support.SecondaryAuthenticator.authenticateAndAttachToContext(SecondaryAuthenticator.java:78) [x-pack-security-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.security.rest.SecurityRestFilter.lambda$handleRequest$2(SecurityRestFilter.java:106) [x-pack-security-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.action.ActionListener$1.onResponse(ActionListener.java:136) [elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.action.ActionListener$MappedActionListener.onResponse(ActionListener.java:101) [elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.action.ActionListener$RunBeforeActionListener.onResponse(ActionListener.java:389) [elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.security.authc.AuthenticatorChain.writeAuthToContext(AuthenticatorChain.java:350) [x-pack-security-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.security.authc.AuthenticatorChain.finishAuthentication(AuthenticatorChain.java:326) [x-pack-security-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.security.authc.AuthenticatorChain.maybeLookupRunAsUser(AuthenticatorChain.java:204) [x-pack-security-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.security.authc.AuthenticatorChain.lambda$doAuthenticate$1(AuthenticatorChain.java:120) [x-pack-security-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.action.ActionListener$1.onResponse(ActionListener.java:136) [elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.core.common.IteratingActionListener.onResponse(IteratingActionListener.java:141) [x-pack-core-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.security.authc.AuthenticatorChain.lambda$getAuthenticatorConsumer$4(AuthenticatorChain.java:187) [x-pack-security-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.action.ActionListener$1.onResponse(ActionListener.java:136) [elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.security.authc.RealmsAuthenticator.lambda$consumeToken$3(RealmsAuthenticator.java:217) [x-pack-security-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.action.ActionListener$1.onResponse(ActionListener.java:136) [elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.action.support.ContextPreservingActionListener.onResponse(ContextPreservingActionListener.java:31) [elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.core.common.IteratingActionListener.onResponse(IteratingActionListener.java:141) [x-pack-core-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.security.authc.RealmsAuthenticator.lambda$consumeToken$0(RealmsAuthenticator.java:162) [x-pack-security-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.action.ActionListener$1.onResponse(ActionListener.java:136) [elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.security.authc.support.CachingUsernamePasswordRealm.lambda$authenticateWithCache$1(CachingUsernamePasswordRealm.java:155) [x-pack-security-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.action.ActionListener$1.onResponse(ActionListener.java:136) [elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.security.authc.support.CachingUsernamePasswordRealm.handleCachedAuthentication(CachingUsernamePasswordRealm.java:242) [x-pack-security-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.security.authc.support.CachingUsernamePasswordRealm.lambda$authenticateWithCache$2(CachingUsernamePasswordRealm.java:139) [x-pack-security-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.action.ActionListener$1.onResponse(ActionListener.java:136) [elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.common.util.concurrent.ListenableFuture.notifyListenerDirectly(ListenableFuture.java:113) [elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.common.util.concurrent.ListenableFuture.addListener(ListenableFuture.java:55) [elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.security.authc.support.CachingUsernamePasswordRealm.authenticateWithCache(CachingUsernamePasswordRealm.java:134) [x-pack-security-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.security.authc.support.CachingUsernamePasswordRealm.authenticate(CachingUsernamePasswordRealm.java:105) [x-pack-security-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.security.authc.RealmsAuthenticator.lambda$consumeToken$2(RealmsAuthenticator.java:146) [x-pack-security-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.core.common.IteratingActionListener.run(IteratingActionListener.java:117) [x-pack-core-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.security.authc.RealmsAuthenticator.consumeToken(RealmsAuthenticator.java:233) [x-pack-security-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.security.authc.RealmsAuthenticator.authenticate(RealmsAuthenticator.java:82) [x-pack-security-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.security.authc.AuthenticatorChain.lambda$getAuthenticatorConsumer$5(AuthenticatorChain.java:179) [x-pack-security-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.core.common.IteratingActionListener.onResponse(IteratingActionListener.java:135) [x-pack-core-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.security.authc.AuthenticatorChain.lambda$getAuthenticatorConsumer$5(AuthenticatorChain.java:157) [x-pack-security-8.2.0-SNA
   │ info PSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.core.common.IteratingActionListener.onResponse(IteratingActionListener.java:135) [x-pack-core-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.security.authc.AuthenticatorChain.lambda$getAuthenticatorConsumer$5(AuthenticatorChain.java:157) [x-pack-security-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.core.common.IteratingActionListener.onResponse(IteratingActionListener.java:135) [x-pack-core-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.security.authc.AuthenticatorChain.lambda$getAuthenticatorConsumer$5(AuthenticatorChain.java:157) [x-pack-security-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.core.common.IteratingActionListener.run(IteratingActionListener.java:117) [x-pack-core-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.security.authc.AuthenticatorChain.doAuthenticate(AuthenticatorChain.java:135) [x-pack-security-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.security.authc.AuthenticatorChain.authenticateAsync(AuthenticatorChain.java:94) [x-pack-security-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.security.authc.AuthenticationService.authenticate(AuthenticationService.java:149) [x-pack-security-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.security.authc.AuthenticationService.authenticate(AuthenticationService.java:127) [x-pack-security-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.xpack.security.rest.SecurityRestFilter.handleRequest(SecurityRestFilter.java:100) [x-pack-security-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.rest.RestController.dispatchRequest(RestController.java:391) [elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.rest.RestController.tryAllHandlers(RestController.java:470) [elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.rest.RestController.dispatchRequest(RestController.java:306) [elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.http.AbstractHttpServerTransport.dispatchRequest(AbstractHttpServerTransport.java:385) [elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.http.AbstractHttpServerTransport.handleIncomingRequest(AbstractHttpServerTransport.java:464) [elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.http.AbstractHttpServerTransport.incomingRequest(AbstractHttpServerTransport.java:359) [elasticsearch-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.http.netty4.Netty4HttpRequestHandler.channelRead0(Netty4HttpRequestHandler.java:32) [transport-netty4-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at org.elasticsearch.http.netty4.Netty4HttpRequestHandler.channelRead0(Netty4HttpRequestHandler.java:18) [transport-netty4-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:99) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
   │      	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
   │      	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
   │      	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
   │      	at org.elasticsearch.http.netty4.Netty4HttpPipeliningHandler.channelRead(Netty4HttpPipeliningHandler.java:48) [transport-netty4-8.2.0-SNAPSHOT.jar:8.2.0-SNAPSHOT]
   │      	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
   │      	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
   │      	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
   │      	at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103) [netty-codec-4.1.73.Final.jar:4.1.73.Final]
   │      	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
   │      	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
   │      	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
   │      	at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103) [netty-codec-4.1.73.Final.jar:4.1.73.Final]
   │      	at io.netty.handler.codec.MessageToMessageCodec.channelRead(MessageToMessageCodec.java:111) [netty-codec-4.1.73.Final.jar:4.1.73.Final]
   │      	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
   │      	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
   │      	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
   │      	at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103) [netty-codec-4.1.73.Final.jar:4.1.73.Final]
   │      	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
   │      	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
   │      	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
   │      	at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103) [netty-codec-4.1.73.Final.jar:4.1.73.Final]
   │      	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
   │      	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
   │      	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
   │      	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:327) [netty-codec-4.1.73.Final.jar:4.1.73.Final]
   │      	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:299) [netty-codec-4.1.73.Final.jar:4.1.73.Final]
   │      	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
   │      	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
   │      	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
   │      	at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:286) [netty-handler-4.1.73.Final.jar:4.1.73.Final]
   │      	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
   │      	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
   │      	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
   │      	at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103) [netty-codec-4.1.73.Final.jar:4.1.73.Final]
   │      	at io.netty.channel.AbstractChannelHandle
   │ info rContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
   │      	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
   │      	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
   │      	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
   │      	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
   │      	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
   │      	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
   │      	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
   │      	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:722) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
   │      	at io.netty.channel.nio.NioEventLoop.processSelectedKeysPlain(NioEventLoop.java:623) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
   │      	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:586) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
   │      	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:496) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
   │      	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986) [netty-common-4.1.73.Final.jar:4.1.73.Final]
   │      	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) [netty-common-4.1.73.Final.jar:4.1.73.Final]
   │      	at java.lang.Thread.run(Thread.java:833) [?:?]
```
server/src/main/java/org/elasticsearch/action/admin/indices/template/post/TransportSimulateIndexTemplateAction.java
SimulateIndexTemplateRequest,
    SimulateIndexTemplateResponse> {
    private final MetadataIndexTemplateService indexTemplateService;
    private final NamedXContentRegistry xContentRegistry;
    private final IndicesService indicesService;
    private final SystemIndices systemIndices;
    private final Set<IndexSettingProvider> indexSettingProviders;
    @Inject
    public TransportSimulateIndexTemplateAction(
        TransportService transportService,
        ClusterService clusterService,
        ThreadPool threadPool,
        MetadataIndexTemplateService indexTemplateService,
        ActionFilters actionFilters,
        IndexNameExpressionResolver indexNameExpressionResolver,
        NamedXContentRegistry xContentRegistry,
        IndicesService indicesService,
        SystemIndices systemIndices,