From 806dd3f604697529ed9e320ebae13db35e586c65 Mon Sep 17 00:00:00 2001 From: Ryan McKinley Date: Sat, 18 Apr 2020 14:59:36 -0700 Subject: [PATCH] QueryEditors: include error when no data is returned (#23632) --- .../dashboard/panel_editor/QueryEditorRow.test.ts | 13 +++++++++++++ .../dashboard/panel_editor/QueryEditorRow.tsx | 7 +++++++ 2 files changed, 20 insertions(+) diff --git a/public/app/features/dashboard/panel_editor/QueryEditorRow.test.ts b/public/app/features/dashboard/panel_editor/QueryEditorRow.test.ts index 886fe081f5f..b0d2c1a661a 100644 --- a/public/app/features/dashboard/panel_editor/QueryEditorRow.test.ts +++ b/public/app/features/dashboard/panel_editor/QueryEditorRow.test.ts @@ -43,4 +43,17 @@ describe('filterPanelDataToQuery', () => { expect(panelData?.series[0].refId).toBe('B'); expect(panelData?.error!.refId).toBe('B'); }); + + it('should include errors when missing data', () => { + const withError = ({ + series: [], + error: { + message: 'Error!!', + }, + } as unknown) as PanelData; + + const panelData = filterPanelDataToQuery(withError, 'B'); + expect(panelData.state).toBe(LoadingState.Error); + expect(panelData.error).toBe(withError.error); + }); }); diff --git a/public/app/features/dashboard/panel_editor/QueryEditorRow.tsx b/public/app/features/dashboard/panel_editor/QueryEditorRow.tsx index a3816754781..55187db555d 100644 --- a/public/app/features/dashboard/panel_editor/QueryEditorRow.tsx +++ b/public/app/features/dashboard/panel_editor/QueryEditorRow.tsx @@ -335,6 +335,13 @@ export function filterPanelDataToQuery(data: PanelData, refId: string): PanelDat // No matching series if (!series.length) { + // If there was an error with no data, pass it to the QueryEditors + if (data.error && !data.series.length) { + return { + ...data, + state: LoadingState.Error, + }; + } return undefined; }