Skip to content
Snippets Groups Projects
Unverified Commit fd7090e5 authored by Paul Rosenzweig's avatar Paul Rosenzweig Committed by GitHub
Browse files

Catch query description errors and improve client error message (#13508)

* catch query description errors and improve client error message

* add test
parent 3717129d
No related branches found
No related tags found
No related merge requests found
......@@ -410,6 +410,9 @@ export function createEntity(def: EntityDefinition): Entity {
// contains the actual entries, if that is on the response we should
// use that as the 'results'
const results = fetched.data ? fetched.data : fetched;
if (!Array.isArray(results)) {
throw `Invalid response listing ${entity.name}`;
}
return {
...entity.normalizeList(results),
entityQuery,
......
(ns metabase.api.query-description
"Functions for generating human friendly query descriptions"
(:require [clojure.string :as str]
[clojure.tools.logging :as log]
[metabase.mbql
[predicates :as mbql.preds]
[util :as mbql.u]]
......@@ -109,6 +110,10 @@
This data structure allows the UI to format the strings appropriately (including JSX)"
[metadata query]
(apply merge
(map (fn [f] (f metadata query))
query-descriptor-functions)))
(try
(apply merge
(map (fn [f] (f metadata query))
query-descriptor-functions))
(catch Exception e
(log/warn e "Error generating query description")
{})))
......@@ -64,7 +64,13 @@
:arg (deferred-tru "[Unknown Metric]")}]}
(sut/generate-query-description (Table (mt/id :venues))
(:query (mt/mbql-query :venues
{:aggregation [[:metric -1]]}))))))
{:aggregation [[:metric -1]]})))))
;; confirm that it doesn't crash for non-integer metrics
(is (= {}
(sut/generate-query-description (Table (mt/id :venues))
(:query (mt/mbql-query :venues
{:aggregation [[:metric "not-a-integer"]]}))))))
(testing "with segment filters"
(tt/with-temp Segment [segment {:name "Test Segment 1"}]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment