### Elasticsearch Version

8.3.0

### Installed Plugins

_No response_

### Java Version

_bundled_

### OS Version

arm64

### Problem Description

When using the `_terms_enum` API, if remote clusters return failures, but the local cluster doesn't, a null exception is thrown:

```
{
  "error": {
    "root_cause": [
      {
        "type": "null_pointer_exception",
        "reason": "Cannot invoke \"java.util.List.add(Object)\" because \"shardFailures\" is null"
      }
    ],
    "type": "null_pointer_exception",
    "reason": "Cannot invoke \"java.util.List.add(Object)\" because \"shardFailures\" is null"
  },
  "status": 500
}
```

### Steps to Reproduce

Call the _terms_enum API with a remote cluster that will return failures, e.g. because of this bug: https://github.com/elastic/elasticsearch/issues/86187

### Logs (if relevant)

_No response_
x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/termsenum/action/TransportTermsEnumAction.java
}
                termsList.add(rc.resp.getTerms());
            } else {
                throw new AssertionError("Unknown atomic response type: " + atomicResponse.getClass().getName());
            }
        }
        List<String> ans = termsList.size() == 1 ? termsList.get(0) : mergeResponses(termsList, request.size());
        return new TermsEnumResponse(ans, (failedShards + successfulShards), successfulShards, failedShards, shardFailures, complete);
    }
    private List<String> mergeResponses(List<List<String>> termsList, int size) {
        final PriorityQueue<TermIterator> pq = new PriorityQueue<>(termsList.size()) {
            @Override
            protected boolean lessThan(TermIterator a, TermIterator b) {
                return a.compareTo(b) < 0;
            }
        };
        for (List<String> terms : termsList) {
            Iterator<String> it = terms.iterator();
            if (it.hasNext()) {
                pq.add(new TermIterator(it));
            }
        }
        String lastTerm = null;
        final List<String> ans = new ArrayList<>();
        while (pq.size() != 0) {
            TermIterator it = pq.top();
            String term = it.term();
            if (lastTerm != null && lastTerm.compareTo(term) != 0) {
                ans.add(lastTerm);
                if (ans.size() == size) {