Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Alternative fix for internal queries (#64376)

dpsuttonf6162a0ccef7
diff --git a/enterprise/backend/test/metabase_enterprise/audit_app/pages_test.clj b/enterprise/backend/test/metabase_enterprise/audit_app/pages_test.clj
index 03af49d15d4..154b751b5c7 100644
--- a/enterprise/backend/test/metabase_enterprise/audit_app/pages_test.clj
+++ b/enterprise/backend/test/metabase_enterprise/audit_app/pages_test.clj
@@ -143,3 +143,18 @@
(doseq [query-type (all-query-methods)]
(testing query-type
(do-tests-for-query-type query-type objects)))))))
+
+(deftest works-over-dataset-api
+ (testing "FE queries work over dataset api (#64383)"
+ (mt/with-premium-features #{:audit-app}
+ (let [response (mt/user-http-request :crowberto :post 202
+ "dataset"
+ {:limit 1
+ :type :internal,
+ :fn "metabase-enterprise.audit-app.pages.queries/bad-table",
+ :args [nil nil nil "last_run_at" "desc"],
+ :offset 0,
+ :parameters []})]
+ (is (=? {:status "completed"
+ :row_count integer?}
+ response))))))
diff --git a/src/metabase/query_processor/api.clj b/src/metabase/query_processor/api.clj
index 80b743fad4d..c664bbab0e7 100644
--- a/src/metabase/query_processor/api.clj
+++ b/src/metabase/query_processor/api.clj
@@ -47,7 +47,8 @@
is a wrapper for the function of the same name in the QP util namespace; it adds additional permissions checking as
well."
[query]
- (when-let [source-card-id (some-> query not-empty lib-be/normalize-query lib/source-card-id)]
+ (when-let [source-card-id (and ((complement #{:internal "internal"}) (:type query))
+ (some-> query not-empty lib-be/normalize-query lib/source-card-id))]
(log/infof "Source query for this query is Card %s" (pr-str source-card-id))
(api/read-check :model/Card source-card-id)
source-card-id))