ui: handle null response properly (#6071)

* web/ui: handle null case

The call might sometimes return /api/v1/label/__name__/values the
following:

```
{"status":"success","data":null}
```

Then the `index.js` file assumes that `data` is not `null`. However,
that assumption fails and then we get this error in the console:

```
graph.js?v=foo:317 Uncaught TypeError: Cannot read property 'length' of null
    at Object.success (graph.js?v=foo:317)
...
```

Then it becomes impossible to, for example, send a simple query like
`time()` and graph the results.

Fix it by using an empty array as the result if it is `null`.

Signed-off-by: Giedrius Statkevičius <giedriuswork@gmail.com>

* ui: update static assets data

Signed-off-by: Giedrius Statkevičius <giedriuswork@gmail.com>
pull/6115/head
Giedrius Statkevičius 5 years ago committed by Chris Marchbanks
parent 84ff928606
commit ad58fc4765

File diff suppressed because one or more lines are too long

@ -271,7 +271,7 @@ Prometheus.Graph.prototype.populateInsertableMetrics = function() {
return;
}
pageConfig.allMetrics = json.data; // todo: do we need self.allMetrics? Or can it just live on the page
pageConfig.allMetrics = json.data || []; // todo: do we need self.allMetrics? Or can it just live on the page
for (var i = 0; i < pageConfig.allMetrics.length; i++) {
self.insertMetric[0].options.add(new Option(pageConfig.allMetrics[i], pageConfig.allMetrics[i]));
}

Loading…
Cancel
Save