The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
GHY-3584: Exclude Python transforms from check entity task (#82979)
Eric Normand4f89083137f5
diff --git a/enterprise/backend/src/metabase_enterprise/dependencies/findings.clj b/enterprise/backend/src/metabase_enterprise/dependencies/findings.cljindex 0fafbe5b4e8..4bedc588254 100644--- a/enterprise/backend/src/metabase_enterprise/dependencies/findings.clj+++ b/enterprise/backend/src/metabase_enterprise/dependencies/findings.clj@@ -23,7 +23,9 @@(defmethod instance-db-id :model/Transform[toucan-instance]- (some-> toucan-instance :source :query lib/database-id))+ (or (some-> toucan-instance :source :query lib/database-id)+ ;; non-query transforms (e.g. Python) have no query to read the database from+ (:source_database_id toucan-instance)))(defmethod instance-db-id :model/Segment[toucan-instance]diff --git a/enterprise/backend/test/metabase_enterprise/dependencies/api_test.clj b/enterprise/backend/test/metabase_enterprise/dependencies/api_test.cljindex 3686d182122..03382108044 100644--- a/enterprise/backend/test/metabase_enterprise/dependencies/api_test.clj+++ b/enterprise/backend/test/metabase_enterprise/dependencies/api_test.clj@@ -6,6 +6,7 @@[metabase-enterprise.dependencies.async :as dependencies.async][metabase-enterprise.dependencies.events][metabase-enterprise.dependencies.findings :as dependencies.findings]+ [metabase-enterprise.dependencies.task.entity-check :as task.entity-check][metabase-enterprise.dependencies.test-util :as deps.test][metabase.collections.models.collection :as collection][metabase.collections.test-utils :refer [personal-collection-id]]@@ -509,6 +510,33 @@(is (= #{(:id dependent-card) (:id next-card)} (set (map :id response2)))"There should two dependents total"))))))))))+(deftest ^:synchronized python-transform-not-broken-after-entity-check-test+ (testing "GHY-3584: a Python transform has no query to validate, so the entity-check task must not record it as broken"+ (mt/with-premium-features #{:dependencies}+ (mt/with-model-cleanup [:model/Dependency :model/DependencyStatus :model/AnalysisFinding :model/AnalysisFindingError]+ (mt/with-temp [:model/Transform {transform-id :id}+ {:name "Python transform - ghy3584"+ :source {:type :python+ :source-database (mt/id)+ :source-tables [{:alias "orders"+ :database_id (mt/id)+ :schema "PUBLIC"+ :table "ORDERS"+ :table_id (mt/id :orders)}]+ :body "def transform(orders):\n return orders"}}]+ (deps.test/synchronously-run-backfill!)+ (#'task.entity-check/check-entities!)+ (let [dependent-ids (fn [broken?]+ (set (map :id (mt/user-http-request :crowberto :get 200 "ee/dependencies/graph/dependents"+ :type "table"+ :id (mt/id :orders)+ :dependent-types "transform"+ :broken broken?))))]+ (is (contains? (dependent-ids false) transform-id)+ "the Python transform is a dependent of the table it reads")+ (is (not (contains? (dependent-ids true) transform-id))+ "the Python transform is not listed as broken")))))))+(deftest graph-permissions-test(testing "GET /api/ee/dependencies/graph requires read permissions on the starting entity"(mt/with-premium-features #{:dependencies}diff --git a/enterprise/backend/test/metabase_enterprise/dependencies/findings_test.clj b/enterprise/backend/test/metabase_enterprise/dependencies/findings_test.cljindex 96800f89922..c8623687cfe 100644--- a/enterprise/backend/test/metabase_enterprise/dependencies/findings_test.clj+++ b/enterprise/backend/test/metabase_enterprise/dependencies/findings_test.clj@@ -304,6 +304,20 @@(stale-map [a-id b-id]))"both cycle members should be drained (re-analyzed, not stale)")))))))))+(deftest ^:synchronized python-transform-records-clean-finding-test+ (testing "GHY-3584: a Python transform has no query, so upsert-analysis! resolves its database from source_database_id and records a clean finding"+ (mt/with-premium-features #{:dependencies}+ (mt/with-model-cleanup [:model/AnalysisFinding :model/AnalysisFindingError]+ (mt/with-temp [:model/Transform {transform-id :id} {:source {:type :python+ :source-database (mt/id)+ :source-tables []+ :body "def transform():\n pass"}}]+ (lib-be/with-metadata-provider-cache+ (deps.findings/upsert-analysis! (t2/select-one :model/Transform transform-id)))+ (is (=? {:result true :stale false}+ (t2/select-one :model/AnalysisFinding :analyzed_entity_type :transform :analyzed_entity_id transform-id)))+ (is (empty? (models.analysis-finding-error/errors-for-entity :transform transform-id))))))))+(deftest ^:synchronized unanalyzable-entity-records-terminal-error-test(testing "A stale entity whose database can't be resolved records a terminal error finding instead of no-oping forever.";; Without the fix, instance-db-id -> nil makes upsert-analysis! no-op: the stale flag is never