Commit 806dd3f6 by Ryan McKinley Committed by GitHub

QueryEditors: include error when no data is returned (#23632)

parent f30074c7
...@@ -43,4 +43,17 @@ describe('filterPanelDataToQuery', () => { ...@@ -43,4 +43,17 @@ describe('filterPanelDataToQuery', () => {
expect(panelData?.series[0].refId).toBe('B'); expect(panelData?.series[0].refId).toBe('B');
expect(panelData?.error!.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);
});
}); });
...@@ -335,6 +335,13 @@ export function filterPanelDataToQuery(data: PanelData, refId: string): PanelDat ...@@ -335,6 +335,13 @@ export function filterPanelDataToQuery(data: PanelData, refId: string): PanelDat
// No matching series // No matching series
if (!series.length) { 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; return undefined;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment