Skip to content

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

Don't fail transform list/fetch when a transform's source reads an inactive table (#83871)

Alexander Polyankin10b3d236d560
diff --git a/src/metabase/transforms/util.clj b/src/metabase/transforms/util.clj
index f700612a6ca..d767cdb9c11 100644
--- a/src/metabase/transforms/util.clj
+++ b/src/metabase/transforms/util.clj
@@ -56,10 +56,10 @@
(qp.setup/with-qp-setup [query query]
(qp.perms/check-query-permissions* (qp.preprocess/preprocess query))
true)
- (catch clojure.lang.ExceptionInfo e
+ (catch Exception e
;; Only a permission refusal makes the source unreadable. A source that fails to preprocess for any
- ;; other reason (a missing required parameter, a malformed query) cannot run at all, and rejecting it
- ;; is left to validation and execution, which report the specific problem.
+ ;; other reason (a missing required parameter, a malformed query, an inactive table) cannot run at all, and
+ ;; rejecting it is left to validation and execution, which report the specific problem.
(let [data (ex-data e)]
(not (or (:permissions-error? data)
(= 403 (:status-code data))))))))
diff --git a/test/metabase/transforms_rest/api/transform_test.clj b/test/metabase/transforms_rest/api/transform_test.clj
index 676c47bf5a4..4d4a2ae0c26 100644
--- a/test/metabase/transforms_rest/api/transform_test.clj
+++ b/test/metabase/transforms_rest/api/transform_test.clj
@@ -599,6 +599,17 @@
(is (some #(true? (:source_readable %)) list-resp)
"At least one transform should have readable sources")))))))))))
+(deftest list-transforms-with-inactive-source-table-test
+ (mt/with-premium-features #{:transforms-basic :hosting}
+ (testing "a transform reading an inactive table does not break listing or fetching transforms"
+ (mt/with-temp [:model/Transform {id :id} {:source {:type :query
+ :query (lib/query (mt/metadata-provider)
+ (lib.metadata/table (mt/metadata-provider)
+ (mt/id :venues)))}}]
+ (mt/with-temp-vals-in-db :model/Table (mt/id :venues) {:active false}
+ (is (some #(= id (:id %)) (mt/user-http-request :crowberto :get 200 "transform")))
+ (is (= id (:id (mt/user-http-request :crowberto :get 200 (format "transform/%d" id))))))))))
+
(deftest filter-transforms-test
(mt/with-premium-features #{:advanced-permissions :transforms-basic :hosting}
(testing "should be able to filter transforms"