From 12d58f3af2eb32b5b206cedaf9b1b5cc0dc6a1f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Mon, 22 Oct 2018 15:26:59 +0200 Subject: [PATCH 1/2] Prevent from uncaught exception: Range filter Error from camshaft when getting analysis query --- .../adapter/analysis-mapconfig-adapter.js | 32 ++++++++++++------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/lib/cartodb/models/mapconfig/adapter/analysis-mapconfig-adapter.js b/lib/cartodb/models/mapconfig/adapter/analysis-mapconfig-adapter.js index 6cd0241d..9fdd2d09 100644 --- a/lib/cartodb/models/mapconfig/adapter/analysis-mapconfig-adapter.js +++ b/lib/cartodb/models/mapconfig/adapter/analysis-mapconfig-adapter.js @@ -107,24 +107,32 @@ AnalysisMapConfigAdapter.prototype.getMapConfig = function(user, requestMapConfi return sourceId2Query; }, {}); - var missingNodesErrors = []; + var analysesErrors = []; requestMapConfig.layers = requestMapConfig.layers.map(function(layer, layerIndex) { if (getLayerSourceId(layer)) { var layerSourceId = getLayerSourceId(layer); var layerNode = sourceId2Node[layerSourceId]; if (layerNode) { - var analysisSql = layerQuery(layerNode); - var sqlQueryWrap = layer.options.sql_wrap; - if (sqlQueryWrap) { - layer.options.sql_raw = analysisSql; - analysisSql = sqlQueryWrap.replace(/<%=\s*sql\s*%>/g, analysisSql); + try { + var analysisSql; + + // it might throw error: Range filter from camshaft, for instance. + analysisSql = layerQuery(layerNode); + + var sqlQueryWrap = layer.options.sql_wrap; + if (sqlQueryWrap) { + layer.options.sql_raw = analysisSql; + analysisSql = sqlQueryWrap.replace(/<%=\s*sql\s*%>/g, analysisSql); + } + layer.options.sql = analysisSql; + layer.options.columns = getDataviewsColumns(getLayerDataviews(layer, dataviews)); + layer.options.affected_tables = getAllAffectedTablesFromSourceNodes(layerNode); + } catch (error) { + analysesErrors.push(error); } - layer.options.sql = analysisSql; - layer.options.columns = getDataviewsColumns(getLayerDataviews(layer, dataviews)); - layer.options.affected_tables = getAllAffectedTablesFromSourceNodes(layerNode); } else { - missingNodesErrors.push( + analysesErrors.push( new Error('Missing analysis node.id="' + layerSourceId +'" for layer='+layerIndex) ); } @@ -133,8 +141,8 @@ AnalysisMapConfigAdapter.prototype.getMapConfig = function(user, requestMapConfi }); var missingDataviewsNodesErrors = getMissingDataviewsSourceIds(dataviews, sourceId2Node); - if (missingNodesErrors.length > 0 || missingDataviewsNodesErrors.length > 0) { - return callback(missingNodesErrors.concat(missingDataviewsNodesErrors)); + if (analysesErrors.length > 0 || missingDataviewsNodesErrors.length > 0) { + return callback(analysesErrors.concat(missingDataviewsNodesErrors)); } // Augment dataviews with sql from analyses From 621b11ebd6e2f0c32b284bb2e494a2a5728436f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Tue, 23 Oct 2018 10:05:53 +0200 Subject: [PATCH 2/2] Update NEWS --- NEWS.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS.md b/NEWS.md index 31cde76b..2e928b25 100644 --- a/NEWS.md +++ b/NEWS.md @@ -12,6 +12,9 @@ New features - `pg-mvt`: Accept trailing semicolon in input queries. - `Renderer Cache Entry`: Do not throw errors for integrity checks. +Bug Fixes: +- Prevent from uncaught exception: Range filter Error from camshaft when getting analysis query. + ## 6.4.0 Released 2018-09-24