String_index_out_of_bounds_exception when attempting to register S3 bucket with Elasticsearch instance

I'm wanting to do a backup & restore on an Elasticsearch 7.10 instance. I've used Terraform to create a role which the user assumes using PassRole which seems to work, however I'm getting an error when attempting to add the S3 bucket I created as part of this process which is as follows:

{
  "error": {
    "root_cause": [
      {
        "type": "string_index_out_of_bounds_exception",
        "reason": "String index out of range: 0"
      }
    ],
    "type": "string_index_out_of_bounds_exception",
    "reason": "String index out of range: 0"
  },
  "status": 500
}

The request looks like this:

PUT _snapshot/test-snapshot
{
  "type": "s3",
  "settings": {
    "bucket": "<<my bucket name>>",
    "role_arn": "arn:aws:iam::**********:role/<<my role>>"
  }
}

Any help much appreciated! Thank you in advance!

Hi @trai and welcome!

role_arn isn't a valid setting. The accepted settings are listed in the docs.

Also 7.10 is really old and wholly unsupported these days, you need to upgrade as a matter of urgency.

Finally, please re-run the API call and add the ?error_trace query parameter so we can see the whole stack trace. Or grab the stack trace from the server logs. The error message String index out of range: 0 on its own is not particularly useful.

Hi David, here is the stack trace you requested.

[2025-01-31T15:25:19,725][WARN ][r.suppressed             ] [dd82828fe8937922ccd5d93f4a41d6e6] path: __PATH__ params: {index=, id=staged-snapshot, type=_snapshot}
RemoteTransportException[[34f09dcf02ed7f394795325b96ec203a][__IP__][__PATH__]]; nested: StringIndexOutOfBoundsException[String index out of range: 0];
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 0
	at java.lang.StringLatin1.charAt(StringLatin1.java:47)
	at java.lang.String.charAt(String.java:693)
	at org.elasticsearch.cluster.metadata.MetadataCreateIndexService.validateIndexOrAliasName(MetadataCreateIndexService.java:237)
	at org.elasticsearch.cluster.metadata.MetadataCreateIndexService.validateIndexName(MetadataCreateIndexService.java:181)
	at org.elasticsearch.cluster.metadata.MetadataCreateIndexService.validate(MetadataCreateIndexService.java:992)
	at org.elasticsearch.cluster.metadata.MetadataCreateIndexService.applyCreateIndexRequest(MetadataCreateIndexService.java:332)
	at org.elasticsearch.cluster.metadata.MetadataCreateIndexService.applyCreateIndexRequest(MetadataCreateIndexService.java:377)
	at org.elasticsearch.action.admin.indices.create.AutoCreateAction$TransportAction$1.execute(AutoCreateAction.java:137)
	at org.elasticsearch.cluster.ClusterStateUpdateTask.execute(ClusterStateUpdateTask.java:47)
	at org.elasticsearch.cluster.service.MasterService.executeTasks(MasterService.java:729)
	at org.elasticsearch.cluster.service.MasterService.calculateTaskOutputs(MasterService.java:344)
	at org.elasticsearch.cluster.service.MasterService.runTasks(MasterService.java:239)
	at org.elasticsearch.cluster.service.MasterService.access$000(MasterService.java:73)
	at org.elasticsearch.cluster.service.MasterService$Batcher.run(MasterService.java:155)
	at org.elasticsearch.cluster.service.TaskBatcher.runIfNotProcessed(TaskBatcher.java:150)
	at org.elasticsearch.cluster.service.TaskBatcher$BatchedTask.run(TaskBatcher.java:188)
	at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingRunnable.run(ThreadContext.java:693)
	at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.runAndClean(PrioritizedEsThreadPoolExecutor.java:252)
	at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.run(PrioritizedEsThreadPoolExecutor.java:215)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.lang.Thread.run(Thread.java:829)

That doesn't look related to repository registration, it's trying (and rightly failing) to auto-create an index with an empty name.

Unfortunately the version you're using is so old that I can't reasonably dig through the code to see what else might be causing this. Please reproduce this on a supported version.