# String\_index\_out\_of\_bounds\_exception when attempting to register S3 bucket with Elasticsearch instance

**URL:** <https://discuss.elastic.co/t/string-index-out-of-bounds-exception-when-attempting-to-register-s3-bucket-with-elasticsearch-instance/373958>\
**Category:** Elasticsearch\
**Tags:** snapshot-and-restore\
**Created:** [January 31, 2025, 4:31pm UTC](https://discuss.elastic.co/t/string-index-out-of-bounds-exception-when-attempting-to-register-s3-bucket-with-elasticsearch-instance/373958 "2025-01-31T16:31:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![trai](https://avatars.discourse-cdn.com/v4/letter/t/b2d939/32.png) [@trai](https://discuss.elastic.co/u/trai)\
**Post date:** [January 31, 2025, 4:31pm UTC](https://discuss.elastic.co/t/string-index-out-of-bounds-exception-when-attempting-to-register-s3-bucket-with-elasticsearch-instance/373958/1 "2025-01-31T16:31:09Z")

</div>

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:

```auto
{
  "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:

```auto
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!

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [January 31, 2025, 5:42pm UTC](https://discuss.elastic.co/t/string-index-out-of-bounds-exception-when-attempting-to-register-s3-bucket-with-elasticsearch-instance/373958/2 "2025-01-31T17:42:48Z")

</div>

Hi @trai and welcome!

`role_arn` isn't a valid setting. The accepted settings are [listed in the docs](https://www.elastic.co/guide/en/elasticsearch/plugins/7.10/repository-s3-repository.html).

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.

---

<div class="post-metadata">

**Author:** ![trai](https://avatars.discourse-cdn.com/v4/letter/t/b2d939/32.png) [@trai](https://discuss.elastic.co/u/trai)\
**Post date:** [February 3, 2025, 1:40pm UTC](https://discuss.elastic.co/t/string-index-out-of-bounds-exception-when-attempting-to-register-s3-bucket-with-elasticsearch-instance/373958/3 "2025-02-03T13:40:42Z")

</div>

Hi David, here is the stack trace you requested.

```auto
[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)

```

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [February 3, 2025, 1:59pm UTC](https://discuss.elastic.co/t/string-index-out-of-bounds-exception-when-attempting-to-register-s3-bucket-with-elasticsearch-instance/373958/4 "2025-02-03T13:59:25Z")

</div>

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.
