Node stats API fails with a Null Pointer exception for data nodes

Hi,

We have recently upgraded to 8.5.0 from 8.4.1. We use the node stats API (_nodes/stats) to pull stats about various nodes for storage into graphite. Since the update all data nodes are showing the following failure when querying using the API

curl -XGET http://esmasters:9200/_nodes/7VyrRwY7RsaNsG9Ku_4mHA/stats?pretty
{
  "_nodes" : {
    "total" : 1,
    "successful" : 0,
    "failed" : 1,
    "failures" : [
      {
        "type" : "failed_node_exception",
        "reason" : "Failed node [7VyrRwY7RsaNsG9Ku_4mHA]",
        "node_id" : "7VyrRwY7RsaNsG9Ku_4mHA",
        "caused_by" : {
          "type" : "null_pointer_exception",
          "reason" : "Cannot invoke \"org.elasticsearch.index.mapper.MapperService.mappingLookup()\" because the return value of \"org.elasticsearch.index.IndexService.mapperService()\" is null"
        }
      }
    ]
  },
  "cluster_name" : "my-cluster",
  "nodes" : { }
}

I tried restarting the nodes and the API works for some time but then again starts failing with above message. The API for master nodes is working fine. Only the data nodes have this problem.

There are no log messages in the the server.json log file related to this error.

Does anybody have any pointers on resolving this?

Thanks

There is an open issue at _nodes/stats returns failed_node_exception if closed indices exist · Issue #91259 · elastic/elasticsearch · GitHub which states this happens if node has closed indices