From 18abd987bb262c839fad38664d07f952c0af3a2f Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Wed, 28 Nov 2018 14:31:20 +0100 Subject: [PATCH] prevent explore from crashing when table is not present in response --- public/app/core/table_model.ts | 5 ++--- public/app/features/explore/Explore.tsx | 12 ++++-------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/public/app/core/table_model.ts b/public/app/core/table_model.ts index 91a7cd0c1fb..fd99db69249 100644 --- a/public/app/core/table_model.ts +++ b/public/app/core/table_model.ts @@ -86,11 +86,10 @@ export function mergeTablesIntoModel(dst?: TableModel, ...tables: TableModel[]): if (arguments.length === 1) { return model; } - // Single query returns data columns and rows as is if (arguments.length === 2) { - model.columns = [...tables[0].columns]; - model.rows = [...tables[0].rows]; + model.columns = tables[0].hasOwnProperty('columns') ? [...tables[0].columns] : []; + model.rows = tables[0].hasOwnProperty('rows') ? [...tables[0].rows] : []; return model; } diff --git a/public/app/features/explore/Explore.tsx b/public/app/features/explore/Explore.tsx index bbd6378d632..70d9beba9b8 100644 --- a/public/app/features/explore/Explore.tsx +++ b/public/app/features/explore/Explore.tsx @@ -784,14 +784,10 @@ export class Explore extends React.PureComponent { //Temp solution... How do detect if ds supports table format? let tableResult; - try { - tableResult = mergeTablesIntoModel( - new TableModel(), - ...queryTransactions.filter(qt => qt.resultType === 'Table' && qt.done && qt.result).map(qt => qt.result) - ); - } catch (error) { - console.log(error); - } + tableResult = mergeTablesIntoModel( + new TableModel(), + ...queryTransactions.filter(qt => qt.resultType === 'Table' && qt.done && qt.result).map(qt => qt.result) + ); const logsResult = datasource && datasource.mergeStreams ? datasource.mergeStreams(