From 009df4fb7a42966e8b145ab47daad5267714afc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=A4ggmark?= Date: Tue, 30 Mar 2021 12:31:48 +0200 Subject: [PATCH] Variables: Fixes Unsupported data format error for null values (#32480) --- public/app/features/variables/query/operators.test.ts | 2 ++ public/app/features/variables/query/operators.ts | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/public/app/features/variables/query/operators.test.ts b/public/app/features/variables/query/operators.test.ts index c3b81000cc6..91f13775402 100644 --- a/public/app/features/variables/query/operators.test.ts +++ b/public/app/features/variables/query/operators.test.ts @@ -290,6 +290,8 @@ describe('areMetricFindValues', () => { ${[{ text: { foo: 1 } }]} | ${false} ${[{ text: Symbol('foo') }]} | ${false} ${[{ text: true }]} | ${false} + ${[{ text: null }]} | ${true} + ${[{ value: null }]} | ${true} ${[]} | ${true} ${[{ text: '' }]} | ${true} ${[{ Text: '' }]} | ${true} diff --git a/public/app/features/variables/query/operators.ts b/public/app/features/variables/query/operators.ts index 5e31cd3b83d..825a651e301 100644 --- a/public/app/features/variables/query/operators.ts +++ b/public/app/features/variables/query/operators.ts @@ -193,7 +193,11 @@ export function areMetricFindValues(data: any[]): data is MetricFindValue[] { continue; } - if (typeof firstValue[firstValueKey] !== 'string' && typeof firstValue[firstValueKey] !== 'number') { + if ( + firstValue[firstValueKey] !== null && + typeof firstValue[firstValueKey] !== 'string' && + typeof firstValue[firstValueKey] !== 'number' + ) { continue; }