Prometheus: Fix exception being thrown when toggling visibility in explore (#60159)

fix error being thrown when frameIndex is out of bounds of dataframe
This commit is contained in:
Galen Kistler 2022-12-12 07:44:15 -06:00 committed by GitHub
parent b71ae13b63
commit b0f8e803a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -119,8 +119,8 @@ export const getVisibleLabels = (config: UPlotConfigBuilder, frames: DataFrame[]
const fieldIndex = plotInstance.props?.dataFrameFieldIndex?.fieldIndex;
if (frameIndex !== undefined && fieldIndex !== undefined) {
const field = frames[frameIndex].fields[fieldIndex];
if (field.labels) {
const field = frames[frameIndex]?.fields[fieldIndex];
if (field?.labels) {
// Note that this may be an empty object in the case of a metric being rendered with no labels
visibleLabels.push({
labels: field.labels,