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
Fix Eastwood findings and restore its aliases (#85522)
Chris Truter5c8dfb629625
diff --git a/.gitignore b/.gitignoreindex 24d80c4cde1..c54094b6737 100644--- a/.gitignore+++ b/.gitignore@@ -12,6 +12,7 @@.DS_Store.\#*.cpcache+.eastwood.bot.idea/.nrepl-portdiff --git a/deps.edn b/deps.ednindex 45aa3598912..4e737e8cb6e 100644--- a/deps.edn+++ b/deps.edn@@ -281,6 +281,9 @@io.zonky.test.postgres/embedded-postgres-binaries-linux-amd64 {:mvn/version "18.3.0"} ; Linux x86_64 (covers ubuntu-latest GH Actions runner)io.zonky.test.postgres/embedded-postgres-binaries-linux-arm64v8 {:mvn/version "18.3.0"} ; Linux arm64io.zonky.test.postgres/embedded-postgres-binaries-windows-amd64 {:mvn/version "18.3.0"} ; Windows x86_64+ jonase/eastwood {:mvn/version "1.4.3" ; inspects namespaces and reports possible problems using tools.analyzer+ :exclusions+ [org.ow2.asm/asm-all]}lambdaisland/deep-diff2 {:mvn/version "2.12.219"} ; way better diffsnet.solovyov/hashp {:mvn/version "0.4.0-1"} ; debugging/spying utilitynrepl/nrepl {:mvn/version "1.5.1"} ; nREPL server@@ -638,6 +641,71 @@"modules/drivers/vertica/src"]:jvm-opts ["-Dclojure.main.report=stderr"]}+ ;; clojure -X:dev:ee:ee-dev:drivers:drivers-dev:test:eastwood+ :eastwood+ {:exec-fn metabase.linters.eastwood/eastwood+ :exec-args {;; source paths only; `:eastwood/test` lints the test paths+ :source-paths ["src"+ "enterprise/backend/src"+ "modules/drivers/athena/src"+ "modules/drivers/bigquery-cloud-sdk/src"+ "modules/drivers/clickhouse/src"+ "modules/drivers/databricks/src"+ "modules/drivers/druid-jdbc/src"+ "modules/drivers/hive-like/src"+ "modules/drivers/mongo/src"+ "modules/drivers/oracle/src"+ "modules/drivers/presto-jdbc/src"+ "modules/drivers/redshift/src"+ "modules/drivers/snowflake/src"+ "modules/drivers/sparksql/src"+ "modules/drivers/sqlserver/src"+ "modules/drivers/starburst/src"+ "modules/drivers/vertica/src"]+ ;; `:wrong-arity` misreads the custom `:arglists` on Toucan and `metabase.test` functions.+ ;; Kondo checks arity anyway.+ ;; The `:suspicious-test` kind restates Eastwood's default, which this list replaces.+ ;; It flags `(is form msg)` whenever it can't tell that `msg` is a string.+ :exclude-linters [:wrong-arity [:suspicious-test :second-arg-is-not-string]]+ ;; Snowplow has a dynamic dependency on okhttp3.CookieJar that we+ ;; don't use but eastwood detects. This is discussed in Slack here+ ;; https://clojurians.slack.com/archives/C03S1KBA2/p1667925853699669+ ;; An issue has been filed here https://github.com/jonase/eastwood/issues/444+ ;; and a simple reproduction repo can be found here https://github.com/metabase/snowplow-eastwood-issue+ ;;+ ;; The two Quartz queue-affinity DriverDelegate shims are `gen-class` namespaces whose+ ;; only body is a `(.superRtp this ...)` call to their own exposed super method. That+ ;; method exists only on the class the namespace itself generates, so `this` can't be+ ;; type-hinted with it at compile time (the class isn't defined yet) — the reflective+ ;; call is unavoidable. Eastwood also can't reliably analyze these gen-class shims.+ :exclude-namespaces [metabase.analytics.snowplow+ metabase.mq.quartz-affinity-delegate-std+ metabase.mq.quartz-affinity-delegate-postgres]}}++ ;; Test counterpart of :eastwood.+ ;;+ ;; clojure -X:dev:dev/test:ee:ee-dev:drivers:drivers-dev:test:eastwood/test+ :eastwood/test+ {:exec-fn metabase.linters.eastwood/eastwood-tests+ :exec-args {:exclude-linters [:wrong-arity [:suspicious-test :second-arg-is-not-string]]+ :exclude-namespaces+ [;; byte/1 dispatch value trips up Eastwood's reader+ metabase.test.http-client+ ;; Cookie/.getName qualified method trips up Eastwood's analyzer+ metabase.server.middleware.settings-cache-test+ ;; .cljc syntax error during Eastwood's analyze+eval phase+ metabase.lib.query-test+ ;; "count not supported on this type: Symbol" in Eastwood's analyzer+ metabase.query-processor.parameters.temporal-units-test+ ;; Syntax error compiling fn* in Eastwood's analyzer+ metabase.sql-tools.macaw.references-test+ ;; Method too large for Eastwood's analyzer+ metabase.sql-tools.sqlglot.references-test+ ;; dev/test namespaces that no longer load; nothing runs them+ dev.deps-graph-test+ dev.migrate-test+ dev.model-tracking-test]}}+;; clojure -T:whitespace-linter:whitespace-linter{:deps {com.github.camsaul/whitespace-linter {:sha "e35bc252ccf5cc74f7d543ef95ad8a3e5131f25b"}}diff --git a/docs/developers-guide/devenv.md b/docs/developers-guide/devenv.mdindex 0d1d4d075c7..2a0a8c6a715 100644--- a/docs/developers-guide/devenv.md+++ b/docs/developers-guide/devenv.md@@ -466,6 +466,10 @@ mage lint-migrations# Load every namespace we ship, failing on reflection warningsclojure -M:ee:drivers:load-namespaces+# Run Eastwood on the source, then on the tests+clojure -X:dev:ee:ee-dev:drivers:drivers-dev:test:eastwood+clojure -X:dev:dev/test:ee:ee-dev:drivers:drivers-dev:test:eastwood/test+# Run the namespace checkerclojure -X:dev:ee:ee-dev:drivers:drivers-dev:test:namespace-checker```diff --git a/enterprise/backend/src/metabase_enterprise/action_v2/api.clj b/enterprise/backend/src/metabase_enterprise/action_v2/api.cljindex f4f20107cf1..be2271f26f7 100644--- a/enterprise/backend/src/metabase_enterprise/action_v2/api.clj+++ b/enterprise/backend/src/metabase_enterprise/action_v2/api.clj@@ -216,11 +216,7 @@:user-id api/*current-user-id*}){:outputs (execute!* action scope params inputs)})-;; TODO (Cam 2025-11-25) please add a response schema to this API endpoint, it makes it easier for our customers to-;; use our API + we will need it when we make auto-TypeScript-signature generation happen-;;-#_{:clj-kondo/ignore [:metabase/validate-defendpoint-has-response-schema]}-(api.macros/defendpoint :post "/execute-form"+(api.macros/defendpoint :post "/execute-form" :- ::data-editing.execute-form/action-description"Temporary endpoint for describing an actions parameterssuch that they can be presented correctly in a modal ahead of execution."[{}@@ -231,7 +227,6 @@[:action ::api-action-id-or-expression][:scope ::types/scope.raw][:input {:optional true} ::action-value-map]]]- :- :metabase-enterprise.action-v2.execute-form/action-description;; This check should be redundant in practice with the permission checks within perform-action!;; Since test coverage is light and the logic is so simple, we've decided to be extra cautious for now.(api/check-superuser)diff --git a/enterprise/backend/src/metabase_enterprise/cache/task/refresh_cache_configs.clj b/enterprise/backend/src/metabase_enterprise/cache/task/refresh_cache_configs.cljindex 7e7b9c2a22a..e710baecc9e 100644--- a/enterprise/backend/src/metabase_enterprise/cache/task/refresh_cache_configs.clj+++ b/enterprise/backend/src/metabase_enterprise/cache/task/refresh_cache_configs.clj@@ -14,7 +14,7 @@[toucan2.core :as t2])(:import(java.util.concurrent Callable ExecutorService SynchronousQueue ThreadPoolExecutor TimeUnit)- (org.apache.commons.lang3.concurrent BasicThreadFactory$Builder)+ (org.apache.commons.lang3.concurrent BasicThreadFactory)(org.quartz.spi MutableTrigger)))(set! *warn-on-reflection* true)@@ -29,7 +29,7 @@100 TimeUnit/SECONDS ;; keep-alive time for idle threads(SynchronousQueue.) ;; direct handoff(.build- (doto (BasicThreadFactory$Builder.)+ (doto (BasicThreadFactory/builder)(.namingPattern "preemptive-caching-thread-pool-%d"))))))#_{:clj-kondo/ignore [:metabase/discourage-dynamic-vars]}diff --git a/enterprise/backend/src/metabase_enterprise/gsheets/api.clj b/enterprise/backend/src/metabase_enterprise/gsheets/api.cljindex 96a905700a9..313f278518c 100644--- a/enterprise/backend/src/metabase_enterprise/gsheets/api.clj+++ b/enterprise/backend/src/metabase_enterprise/gsheets/api.clj@@ -340,7 +340,7 @@stop showing the setup widget.Returns the gsheets shape, with the attached datawarehouse db id at `:db_id`."- [] :- :gsheets/response+ [](handle-get-connection))(mu/defn- hm-sync-conn! :- :hm-client/http-replydiff --git a/enterprise/backend/src/metabase_enterprise/permission_debug/impl.clj b/enterprise/backend/src/metabase_enterprise/permission_debug/impl.cljindex bcd9f8d21e1..d081450b0be 100644--- a/enterprise/backend/src/metabase_enterprise/permission_debug/impl.clj+++ b/enterprise/backend/src/metabase_enterprise/permission_debug/impl.clj@@ -84,7 +84,6 @@(mu/defmethod debug-permissions ::is-superuser :- DebuggerSchema[{:keys [action-type model-id]} :- DebuggerArguments]- (){:decision "allow":model-type (case (namespace action-type)"card" "card")diff --git a/enterprise/backend/src/metabase_enterprise/search/semantic/index.clj b/enterprise/backend/src/metabase_enterprise/search/semantic/index.cljindex 30d4551e215..d33f6aecf70 100644--- a/enterprise/backend/src/metabase_enterprise/search/semantic/index.clj+++ b/enterprise/backend/src/metabase_enterprise/search/semantic/index.clj@@ -1062,7 +1062,8 @@(zero? (.getNumIdleConnectionsDefaultUser ^PooledDataSource db)))(future(u/ignore-exceptions- (with-open [_conn (.getConnection ^PooledDataSource db)]))))))+ ;; Closing a pooled connection returns it to the pool, where it waits idle for the query.+ (.close (.getConnection ^PooledDataSource db)))))));; ----------------------------------------------------------------------------------------------------------;; Gated vector-search instrumentationdiff --git a/enterprise/backend/src/metabase_enterprise/transforms_python/s3.clj b/enterprise/backend/src/metabase_enterprise/transforms_python/s3.cljindex 29911dca72f..ca2e8070958 100644--- a/enterprise/backend/src/metabase_enterprise/transforms_python/s3.clj+++ b/enterprise/backend/src/metabase_enterprise/transforms_python/s3.clj@@ -63,6 +63,9 @@(defn- delete-object-request ^DeleteObjectRequest [^String bucket-name ^String key](-> (DeleteObjectRequest/builder) (.bucket bucket-name) (.key key) .build))+(defonce ^:private default-credentials-provider+ (delay (.build (DefaultCredentialsProvider/builder))))+(defn- maybe-with-credentials*[credentials-provider](let [access-key (transforms-python.settings/python-storage-s-3-access-key)@@ -72,11 +75,11 @@(do (log/warnf "Ignoring %s because %s is not defined"(if access-key "access-key" "secret-key")(if (not access-key) "access-key" "secret-key"))- (credentials-provider (DefaultCredentialsProvider/create)))+ (credentials-provider @default-credentials-provider))(credentials-provider(StaticCredentialsProvider/create(AwsBasicCredentials/create access-key secret-key))))- (credentials-provider (DefaultCredentialsProvider/create)))))+ (credentials-provider @default-credentials-provider))))(defn- maybe-with-credentials-s3-client [^S3ClientBuilder builder](maybe-with-credentials* #(.credentialsProvider builder ^AwsCredentialsProvider %)))diff --git a/enterprise/backend/test/metabase_enterprise/audit_app/audit_test.clj b/enterprise/backend/test/metabase_enterprise/audit_app/audit_test.cljindex 453475dfb1d..6ba2443a9ef 100644--- a/enterprise/backend/test/metabase_enterprise/audit_app/audit_test.clj+++ b/enterprise/backend/test/metabase_enterprise/audit_app/audit_test.clj@@ -40,9 +40,10 @@(finally(mbc/ensure-audit-db-installed!))))-(defmacro with-audit-db-restoration! [& body]+(defmacro with-audit-db-restoration!"Calls `ensure-audit-db-installed!` before and after `body` to ensure that the audit DB is installed and thenrestored if necessary. Also disables audit content loading if it is already loaded."+ [& body]`(do-with-audit-db-restoration! (fn [] ~@body)))(deftest audit-db-installation-test@@ -171,7 +172,7 @@resource "migrations/instance_analytics_views"entries [["users/v1/postgres-users.sql" "select 1;"]["dashboards/v1/postgres-dashboards.sql" "select 2;"]]- jar-url (java.net.URL. (format "jar:%s!/%s" (.toUri jar-path) resource))+ jar-url (.toURL (java.net.URI. (format "jar:%s!/%s" (.toUri jar-path) resource)))expected (hash (sort-by first (mapv (fn [[rel sql]] [rel sql]) entries)))](try(with-open [out (-> jar-path@@ -203,7 +204,7 @@(.putNextEntry out (JarEntry. (str resource "/" rel)))(.write out (.getBytes ^String sql StandardCharsets/UTF_8))(.closeEntry out)))- [jar-path (java.net.URL. (format "jar:%s!/%s" (.toUri jar-path) resource))]))+ [jar-path (.toURL (java.net.URI. (format "jar:%s!/%s" (.toUri jar-path) resource)))]))[jar-a url-a] (make-jar [["a.sql" "select 1;"]])[jar-b url-b] (make-jar [["b.sql" "select 1;"]])](trydiff --git a/enterprise/backend/test/metabase_enterprise/custom_viz_plugin/models/custom_viz_plugin_test.clj b/enterprise/backend/test/metabase_enterprise/custom_viz_plugin/models/custom_viz_plugin_test.cljindex 45e5f6b0b00..986067e1ae6 100644--- a/enterprise/backend/test/metabase_enterprise/custom_viz_plugin/models/custom_viz_plugin_test.clj+++ b/enterprise/backend/test/metabase_enterprise/custom_viz_plugin/models/custom_viz_plugin_test.clj@@ -110,21 +110,21 @@(deftest bundle-b64-round-trip-test(testing "bundle bytes base64-encode on export and decode back to bytes on import"- (let [spec (serdes/make-spec "CustomVizPlugin" {})- export (get-in spec [:transform :bundle :export])- import (get-in spec [:transform :bundle :import])- bytes (.getBytes "pretend tgz bytes" "UTF-8")- out (export bytes)]+ (let [spec (serdes/make-spec "CustomVizPlugin" {})+ export-fn (get-in spec [:transform :bundle :export])+ import-fn (get-in spec [:transform :bundle :import])+ bytes (.getBytes "pretend tgz bytes" "UTF-8")+ out (export-fn bytes)](is (string? out))(is (not= (String. bytes "UTF-8") out)"exported value should be b64-encoded, not the raw string")- (is (= (seq bytes) (seq (import out))))))+ (is (= (seq bytes) (seq (import-fn out))))))(testing "nil bundle round-trips as nil"- (let [spec (serdes/make-spec "CustomVizPlugin" {})- export (get-in spec [:transform :bundle :export])- import (get-in spec [:transform :bundle :import])]- (is (nil? (export nil)))- (is (nil? (import nil))))))+ (let [spec (serdes/make-spec "CustomVizPlugin" {})+ export-fn (get-in spec [:transform :bundle :export])+ import-fn (get-in spec [:transform :bundle :import])]+ (is (nil? (export-fn nil)))+ (is (nil? (import-fn nil))))))(defn- ingested-plugin"What serdes ingests for an export of plugin `identifier` whose bundle bytes are `bundle`."diff --git a/enterprise/backend/test/metabase_enterprise/dependencies/hooks_test.clj b/enterprise/backend/test/metabase_enterprise/dependencies/hooks_test.cljindex 0def4bf8e25..2e8f5d73f5e 100644--- a/enterprise/backend/test/metabase_enterprise/dependencies/hooks_test.clj+++ b/enterprise/backend/test/metabase_enterprise/dependencies/hooks_test.clj@@ -129,22 +129,22 @@(mt/with-premium-features #{:dependencies}(with-card-and-dependent!:orders- (fn [processed! pending?]+ (fn [processed! both-pending?](processed!)(mt/with-temp [:model/Dimension _ {:field_id (mt/id :orders :product_id):type :external:name "Product":human_readable_field_id (mt/id :products :title)}](testing "adding the remap"- (is (pending?)))+ (is (both-pending?)))(testing "changing its human-readable field"(processed!)(mt/with-temp-vals-in-db :model/Field (mt/id :products :title) {:display_name "Renamed"}- (is (pending?))))+ (is (both-pending?))))(testing "a user setting of its human-readable field"(processed!)(mt/with-temp [:model/FieldUserSettings _ {:field_id (mt/id :products :title) :display_name "Item"}]- (is (pending?))))))))))+ (is (both-pending?))))))))))(deftest internal-remap-values-mark-transitive-dependents-test(testing "the FieldValues of an internally remapped field mark every card carrying the remapped column when they gain@@ -152,15 +152,15 @@(mt/with-premium-features #{:dependencies}(with-card-and-dependent!:venues- (fn [processed! pending?]+ (fn [processed! both-pending?](mt/with-temp [:model/Dimension _ {:field_id (mt/id :venues :price) :type :internal :name "Price"}:model/FieldValues fv {:field_id (mt/id :venues :price) :type :full:values [1 2 3 4] :human_readable_values []}](processed!)(t2/update! :model/FieldValues (:id fv) {:values [1 2 3 4 5]})- (is (not (pending?)))+ (is (not (both-pending?)))(t2/update! :model/FieldValues (:id fv) {:human_readable_values ["$" "$$" "$$$" "$$$$" "$$$$$"]})- (is (pending?))))))))+ (is (both-pending?))))))))(deftest batched-marks-test(testing "a batch of field writes marks the cards reading their table once per status, and triggers the jobs once"diff --git a/enterprise/backend/test/metabase_enterprise/gsheets/api_test.clj b/enterprise/backend/test/metabase_enterprise/gsheets/api_test.cljindex 5aa74a612d5..2dc329daaa8 100644--- a/enterprise/backend/test/metabase_enterprise/gsheets/api_test.clj+++ b/enterprise/backend/test/metabase_enterprise/gsheets/api_test.clj@@ -131,8 +131,9 @@"A 200 'error' response from HM. nb: if you change this, change it in test_resources/gsheets/mock_hm_responses.edn""e8653c8d-4d86-4ebc-92a3-0468252b9d07")-(defmacro with-sample-db-as-dwh [& body]+(defmacro with-sample-db-as-dwh"We need an attached dwh for these tests, so let's have the sample db fill in for us:"+ [& body](let [db-sym (gensym "db-")]`(mt/with-temp [:model/Database ~db-sym {:is_attached_dwh true}]~@body)))diff --git a/enterprise/backend/test/metabase_enterprise/gsheets/settings_test.clj b/enterprise/backend/test/metabase_enterprise/gsheets/settings_test.cljindex 103e17e56f1..35e079d09df 100644--- a/enterprise/backend/test/metabase_enterprise/gsheets/settings_test.clj+++ b/enterprise/backend/test/metabase_enterprise/gsheets/settings_test.clj@@ -5,8 +5,9 @@[metabase.settings.core :as setting][toucan2.core :as t2]))-(defmacro with-sample-db-as-dwh [& body]+(defmacro with-sample-db-as-dwh"We need an attached dwh for these tests, so let's have the sample db fill in for us:"+ [& body]`(try(t2/update! :model/Database :id 1 {:is_attached_dwh true})~@bodydiff --git a/enterprise/backend/test/metabase_enterprise/remote_sync/impl_progress_test.clj b/enterprise/backend/test/metabase_enterprise/remote_sync/impl_progress_test.cljindex 08013308a9a..3ddfd36b24c 100644--- a/enterprise/backend/test/metabase_enterprise/remote_sync/impl_progress_test.clj+++ b/enterprise/backend/test/metabase_enterprise/remote_sync/impl_progress_test.clj@@ -120,7 +120,7 @@(replace-all! [_] nil)(empty-commit? [_] false)(finish-commit! [_ _message] "sha")- (finish-commit! [_ _message report] (when report (report 0.8 {:force? true})) "sha")+ (finish-commit! [_ _message report!] (when report! (report! 0.8 {:force? true})) "sha")(abort-commit! [_] nil))](mt/with-dynamic-fn-redefs [source.p/open-commit (fn [_] commit)](#'impl/commit-staged! {:managed-dirs []} "msg"diff --git a/enterprise/backend/test/metabase_enterprise/remote_sync/models/remote_sync_task_test.clj b/enterprise/backend/test/metabase_enterprise/remote_sync/models/remote_sync_task_test.cljindex 8c7eb4a1f8a..420dbc43334 100644--- a/enterprise/backend/test/metabase_enterprise/remote_sync/models/remote_sync_task_test.clj+++ b/enterprise/backend/test/metabase_enterprise/remote_sync/models/remote_sync_task_test.clj@@ -672,35 +672,35 @@(deftest make-progress-reporter-throttles-and-forces-test(testing "intra-phase writes are throttled; :force? bypasses the throttle; boundaries always land"- (let [now (atom 0)- writes (atom [])- report (rst/make-progress-reporter 1 {:throttle-ms 10000- :now-fn (fn [] @now)- :write-fn (fn [f] (swap! writes conj f))})]- (report 0.33 {:force? true}) ; boundary — always writes- (report 0.40) ; 0ms since last throttled anchor set by forced write -> throttled out- (reset! now 5000) (report 0.50) ; 5s < 10s -> throttled out- (reset! now 10000) (report 0.60) ; 10s -> writes- (report 0.66 {:force? true}) ; boundary -> writes+ (let [now (atom 0)+ writes (atom [])+ report! (rst/make-progress-reporter 1 {:throttle-ms 10000+ :now-fn (fn [] @now)+ :write-fn (fn [f] (swap! writes conj f))})]+ (report! 0.33 {:force? true}) ; boundary — always writes+ (report! 0.40) ; 0ms since last throttled anchor set by forced write -> throttled out+ (reset! now 5000) (report! 0.50) ; 5s < 10s -> throttled out+ (reset! now 10000) (report! 0.60) ; 10s -> writes+ (report! 0.66 {:force? true}) ; boundary -> writes(is (= [0.33 0.60 0.66] @writes)))))(deftest make-progress-reporter-is-monotonic-test(testing "the reporter never writes a fraction lower than the last written"- (let [now (atom 0)- writes (atom [])- report (rst/make-progress-reporter 1 {:throttle-ms 0- :now-fn (fn [] @now)- :write-fn (fn [f] (swap! writes conj f))})]- (report 0.5)- (report 0.4) ; lower -> dropped- (report 0.6)+ (let [now (atom 0)+ writes (atom [])+ report! (rst/make-progress-reporter 1 {:throttle-ms 0+ :now-fn (fn [] @now)+ :write-fn (fn [f] (swap! writes conj f))})]+ (report! 0.5)+ (report! 0.4) ; lower -> dropped+ (report! 0.6)(is (= [0.5 0.6] @writes)))))(deftest make-progress-reporter-clamps-test(testing "fractions are clamped into [0.0, 1.0]"- (let [writes (atom [])- report (rst/make-progress-reporter 1 {:throttle-ms 0- :now-fn (constantly 0)- :write-fn (fn [f] (swap! writes conj f))})]- (report 1.5)+ (let [writes (atom [])+ report! (rst/make-progress-reporter 1 {:throttle-ms 0+ :now-fn (constantly 0)+ :write-fn (fn [f] (swap! writes conj f))})]+ (report! 1.5)(is (= [1.0] @writes)))))diff --git a/enterprise/backend/test/metabase_enterprise/remote_sync/source/git_test.clj b/enterprise/backend/test/metabase_enterprise/remote_sync/source/git_test.cljindex 91b7de837ff..0fcf20fefe1 100644--- a/enterprise/backend/test/metabase_enterprise/remote_sync/source/git_test.clj+++ b/enterprise/backend/test/metabase_enterprise/remote_sync/source/git_test.clj@@ -506,9 +506,9 @@(deftest write-special-collections(let [subdir-path (str "collections/" "r" (subs (u/generate-nano-id "a") 1) "_subdir/")](mt/with-temp-dir [remote-dir nil]- (let [[_master _remote] (init-source! "master" remote-dir- :files {"master.txt" "File in master"- (str subdir-path "path.txt") "File in subdir"})]))))+ (init-source! "master" remote-dir+ :files {"master.txt" "File in master"+ (str subdir-path "path.txt") "File in subdir"}))))(deftest concurrent-access(mt/with-temp-dir [remote-dir nil]diff --git a/enterprise/backend/test/metabase_enterprise/search/semantic/index_embedding_test.clj b/enterprise/backend/test/metabase_enterprise/search/semantic/index_embedding_test.cljindex 11febeb37a0..ad22fc36b8d 100644--- a/enterprise/backend/test/metabase_enterprise/search/semantic/index_embedding_test.clj+++ b/enterprise/backend/test/metabase_enterprise/search/semantic/index_embedding_test.clj@@ -31,12 +31,12 @@:model-name test-long-model-name:vector-dimensions test-vector-dimensions})))))(testing "remains unique"- (not= (name-func (semantic.index/default-index {:provider test-provider- :model-name (str test-long-model-name "a")- :vector-dimensions test-vector-dimensions}))- (name-func (semantic.index/default-index {:provider test-provider- :model-name (str test-long-model-name "aa")- :vector-dimensions test-vector-dimensions})))))+ (is (not= (name-func (semantic.index/default-index {:provider test-provider+ :model-name (str test-long-model-name "a")+ :vector-dimensions test-vector-dimensions}))+ (name-func (semantic.index/default-index {:provider test-provider+ :model-name (str test-long-model-name "aa")+ :vector-dimensions test-vector-dimensions}))))))(testing "short"(is (>= 63 (count (name-func (semantic.index/default-index {:provider test-provider:model-name test-short-model-namediff --git a/enterprise/backend/test/metabase_enterprise/search/semantic/migration_test.clj b/enterprise/backend/test/metabase_enterprise/search/semantic/migration_test.cljindex b4ca250aafe..5472a5f6da2 100644--- a/enterprise/backend/test/metabase_enterprise/search/semantic/migration_test.clj+++ b/enterprise/backend/test/metabase_enterprise/search/semantic/migration_test.clj@@ -215,7 +215,7 @@;; (maybe-migrate! is called inside with-migrate-tx, after the lock)#'semantic.db.migration/maybe-migrate!(fn [& args]- (let [tid (.getId (Thread/currentThread))]+ (let [tid (.threadId (Thread/currentThread))](swap! results update :log conj [tid :started (t/local-date-time)])(try(Thread/sleep 200)diff --git a/enterprise/backend/test/metabase_enterprise/search/semantic/scoring_test.clj b/enterprise/backend/test/metabase_enterprise/search/semantic/scoring_test.cljindex f008a9769b2..8299aa136ba 100644--- a/enterprise/backend/test/metabase_enterprise/search/semantic/scoring_test.clj+++ b/enterprise/backend/test/metabase_enterprise/search/semantic/scoring_test.clj@@ -428,7 +428,6 @@{:model "card" :id 2 :name "never viewed card"}](testing "Transform ranks between recently viewed and never viewed cards"(let [results (search-results :user-recency "card" {:current-user-id user-id})]- (def results results)(is (= [["card" c1 "recently viewed card"]["transform" 1 "transform no views"]["card" 2 "never viewed card"]]diff --git a/enterprise/backend/test/metabase_enterprise/serialization/v2/dependency_validation_test.clj b/enterprise/backend/test/metabase_enterprise/serialization/v2/dependency_validation_test.cljindex 836557bbdd7..6ca2f9cb2e6 100644--- a/enterprise/backend/test/metabase_enterprise/serialization/v2/dependency_validation_test.clj+++ b/enterprise/backend/test/metabase_enterprise/serialization/v2/dependency_validation_test.clj@@ -29,7 +29,7 @@Warnings are logged before the abort, so callers can still assert on the logged messages."[opts](is (thrown-with-msg? clojure.lang.ExceptionInfo #"incomplete export"- (into [] (extract/extract opts)))))+ (dorun (extract/extract opts)))))(deftest escape-report-test(mt/with-empty-h2-app-db!diff --git a/enterprise/backend/test/metabase_enterprise/serialization/v2/extract_test.clj b/enterprise/backend/test/metabase_enterprise/serialization/v2/extract_test.cljindex a96cd05884d..75c83860447 100644--- a/enterprise/backend/test/metabase_enterprise/serialization/v2/extract_test.clj+++ b/enterprise/backend/test/metabase_enterprise/serialization/v2/extract_test.clj@@ -49,7 +49,7 @@Escape warnings are logged before the abort, so callers can still assert on the logged messages."[opts](is (thrown-with-msg? clojure.lang.ExceptionInfo #"incomplete export"- (into [] (extract/extract opts)))))+ (dorun (extract/extract opts)))))(deftest fundamentals-test(mt/with-empty-h2-app-db!@@ -1282,15 +1282,15 @@:model/FieldUserSettings _ {:field_id f2-id :description "curated"}:model/TableUserSettings _ {:table_id table-id :display_name "Renamed"}](testing "targeting the collection exports the Table and its Fields, each beside its user settings"- (let [entities (into [] (extract/extract {:targets [["Collection" coll-id]]- :no-data-model true}))- by-model (group-by (comp :model last :serdes/meta) entities)]- (is (some #(= "T" (:name %)) (by-model "Table")))+ (let [entities (into [] (extract/extract {:targets [["Collection" coll-id]]+ :no-data-model true}))+ model->entities (group-by (comp :model last :serdes/meta) entities)]+ (is (some #(= "T" (:name %)) (model->entities "Table")))(is (= #{"F1" "F2"}- (set (map :name (by-model "Field")))))- (is (= 1 (count (by-model "TableUserSettings"))))+ (set (map :name (model->entities "Field")))))+ (is (= 1 (count (model->entities "TableUserSettings"))))(is (= #{"F2"}- (set (map #(-> % :serdes/meta (nth 2) :id) (by-model "FieldUserSettings"))))+ (set (map #(-> % :serdes/meta (nth 2) :id) (model->entities "FieldUserSettings"))))"only the field the user edited has settings to export"))))))(deftest cards-testdiff --git a/enterprise/backend/test/metabase_enterprise/sso/integrations/saml_test.clj b/enterprise/backend/test/metabase_enterprise/sso/integrations/saml_test.cljindex ef05d2507b3..ef348e1ba9d 100644--- a/enterprise/backend/test/metabase_enterprise/sso/integrations/saml_test.clj+++ b/enterprise/backend/test/metabase_enterprise/sso/integrations/saml_test.clj@@ -25,7 +25,7 @@[toucan2.core :as t2])(:import(java.io ByteArrayInputStream)- (java.net URL)+ (java.net URI)(java.nio.charset StandardCharsets)(java.util.zip Inflater InflaterInputStream)(org.apache.commons.io IOUtils)@@ -167,7 +167,7 @@(assert (string? uri-str))(into{}- (for [^BasicNameValuePair pair (-> (URL. uri-str) .getQuery (URLEncodedUtils/parse StandardCharsets/UTF_8))]+ (for [^BasicNameValuePair pair (-> (URI. uri-str) .getRawQuery (URLEncodedUtils/parse StandardCharsets/UTF_8))][(keyword (.getName pair)) (.getValue pair)])))(deftest ^:parallel uri->params-map-testdiff --git a/enterprise/backend/test/metabase_enterprise/stale/api_test.clj b/enterprise/backend/test/metabase_enterprise/stale/api_test.cljindex 11a5990245e..b73b9d28b1a 100644--- a/enterprise/backend/test/metabase_enterprise/stale/api_test.clj+++ b/enterprise/backend/test/metabase_enterprise/stale/api_test.clj@@ -59,9 +59,9 @@(testing "count is correct"(is (= 4 (:total result))))(testing "Contains the correct data"- (= #{["card" (u/the-id card)] ["dashboard" (u/the-id dashboard)]- ["card" (u/the-id card-2)] ["dashboard" (u/the-id dashboard-2)]}- (->> result :data (map (juxt :model :id)) set)))))))))+ (is (= #{["card" (u/the-id card)] ["dashboard" (u/the-id dashboard)]+ ["card" (u/the-id card-2)] ["dashboard" (u/the-id dashboard-2)]}+ (->> result :data (map (juxt :model :id)) set))))))))))(deftest recursive-search-skips-archived-descendants-test(testing "a recursive search does not descend into archived collections"diff --git a/modules/drivers/clickhouse/test/metabase/driver/clickhouse_impersonation_test.clj b/modules/drivers/clickhouse/test/metabase/driver/clickhouse_impersonation_test.cljindex bc950db57d5..5556a616690 100644--- a/modules/drivers/clickhouse/test/metabase/driver/clickhouse_impersonation_test.clj+++ b/modules/drivers/clickhouse/test/metabase/driver/clickhouse_impersonation_test.clj@@ -45,16 +45,13 @@:clickhouse spec nil(fn [^java.sql.Connection conn](driver/set-role! :clickhouse conn default-role)- (fn [^java.sql.Connection conn]- (driver/set-role! :clickhouse conn default-role)- (with-open [stmt (.prepareStatement conn "SELECT * FROM `metabase_test_role_db`.`some_table` ORDER BY i ASC;")- rset (.executeQuery stmt)]- (is (true? (.next rset)))- (is (= 42 (.getInt rset 1)))- (is (true? (.next rset)))- (is (= 144 (.getInt rset 1)))- (is (false? (.next rset)))))))- (is true))))+ (with-open [stmt (.prepareStatement conn "SELECT * FROM `metabase_test_role_db`.`some_table` ORDER BY i ASC;")+ rset (.executeQuery stmt)]+ (is (true? (.next rset)))+ (is (= 42 (.getInt rset 1)))+ (is (true? (.next rset)))+ (is (= 144 (.getInt rset 1)))+ (is (false? (.next rset)))))))))(defn- set-role-throws-test![details-map]@@ -112,6 +109,9 @@ENGINE ReplicatedMergeTree('/clickhouse/{cluster}/tables/{database}/{table}/{shard}', '{replica}')ORDER BY (i);""INSERT INTO `metabase_test_role_db`.`some_table` VALUES (42), (144);"+ ;; the test reads through the load balancer, so it can reach a replica the rows haven't+ ;; reached yet+ "SYSTEM SYNC REPLICA ON CLUSTER '{cluster}' `metabase_test_role_db`.`some_table`;""CREATE ROLE IF NOT EXISTS `metabase_test_role` ON CLUSTER '{cluster}';""CREATE ROLE IF NOT EXISTS `metabase-test-role` ON CLUSTER '{cluster}';""CREATE USER IF NOT EXISTS `metabase_test_user` ON CLUSTER '{cluster}' NOT IDENTIFIED;"@@ -220,4 +220,4 @@(with-ssh-tunnel! (assoc tunnel-details :tunnel-pass "wrong-password")(is (thrown-with-msg?org.apache.sshd.common.SshException #"No more authentication methods available"- (count (mt/rows (qp/process-query (mt/mbql-query venues)))))))))))))+ (mt/rows (qp/process-query (mt/mbql-query venues))))))))))))diff --git a/modules/drivers/clickhouse/test/metabase/driver/clickhouse_temporal_bucketing_test.clj b/modules/drivers/clickhouse/test/metabase/driver/clickhouse_temporal_bucketing_test.cljindex 7b11c2e8c3b..9395fdf30dc 100644--- a/modules/drivers/clickhouse/test/metabase/driver/clickhouse_temporal_bucketing_test.clj+++ b/modules/drivers/clickhouse/test/metabase/driver/clickhouse_temporal_bucketing_test.clj@@ -30,158 +30,158 @@(deftest clickhouse-temporal-bucketing-server-tz(mt/test-driver :clickhouse(mt/dataset temporal_bucketing_db- (defn- start-of-year! [unit]- (->> {:breakout [[:field %start_of_year {:temporal-unit unit}]]}- (mt/run-mbql-query temporal_bucketing_server_tz)- mt/rows))- (defn- mid-year! [unit]- (->> {:breakout [[:field %mid_of_year {:temporal-unit unit}]]}- (mt/run-mbql-query temporal_bucketing_server_tz)- mt/rows))- (defn- end-of-year! [unit]- (->> {:breakout [[:field %end_of_year {:temporal-unit unit}]]}- (mt/run-mbql-query temporal_bucketing_server_tz)- mt/rows))- (testing "truncate to"- (testing "minute"- (is (= [["2022-06-20T06:32:00Z"]]- (mid-year! :minute))))- (testing "hour"- (is (= [["2022-06-20T06:00:00Z"]]- (mid-year! :hour))))- (testing "day"- (is (= [["2022-06-20T00:00:00Z"]]- (mid-year! :day))))- (testing "month"- (is (= [["2022-06-01T00:00:00Z"]]- (mid-year! :month))))- (testing "quarter"- (is (= [["2022-04-01T00:00:00Z"]]- (mid-year! :quarter))))- (testing "year"- (is (= [["2022-01-01T00:00:00Z"]]- (mid-year! :year)))))- (testing "extract"- (testing "minute of hour"- (is (= [[0]]- (start-of-year! :minute-of-hour)))- (is (= [[32]]- (mid-year! :minute-of-hour)))- (is (= [[59]]- (end-of-year! :minute-of-hour))))- (testing "hour of day"- (is (= [[0]]- (start-of-year! :hour-of-day)))- (is (= [[6]]- (mid-year! :hour-of-day)))- (is (= [[23]]- (end-of-year! :hour-of-day))))- (testing "day of month"- (is (= [[1]]- (start-of-year! :day-of-month)))- (is (= [[20]]- (mid-year! :day-of-month)))- (is (= [[31]]- (end-of-year! :day-of-month))))- (testing "day of year"- (is (= [[1]]- (start-of-year! :day-of-year)))- (is (= [[171]]- (mid-year! :day-of-year)))- (is (= [[365]]- (end-of-year! :day-of-year))))- (testing "month of year"- (is (= [[1]]- (start-of-year! :month-of-year)))- (is (= [[6]]- (mid-year! :month-of-year)))- (is (= [[12]]- (end-of-year! :month-of-year))))- (testing "quarter of year"- (is (= [[1]]- (start-of-year! :quarter-of-year)))- (is (= [[2]]- (mid-year! :quarter-of-year)))- (is (= [[4]]- (end-of-year! :quarter-of-year))))))))+ (letfn [(start-of-year! [unit]+ (->> {:breakout [[:field %start_of_year {:temporal-unit unit}]]}+ (mt/run-mbql-query temporal_bucketing_server_tz)+ mt/rows))+ (mid-year! [unit]+ (->> {:breakout [[:field %mid_of_year {:temporal-unit unit}]]}+ (mt/run-mbql-query temporal_bucketing_server_tz)+ mt/rows))+ (end-of-year! [unit]+ (->> {:breakout [[:field %end_of_year {:temporal-unit unit}]]}+ (mt/run-mbql-query temporal_bucketing_server_tz)+ mt/rows))]+ (testing "truncate to"+ (testing "minute"+ (is (= [["2022-06-20T06:32:00Z"]]+ (mid-year! :minute))))+ (testing "hour"+ (is (= [["2022-06-20T06:00:00Z"]]+ (mid-year! :hour))))+ (testing "day"+ (is (= [["2022-06-20T00:00:00Z"]]+ (mid-year! :day))))+ (testing "month"+ (is (= [["2022-06-01T00:00:00Z"]]+ (mid-year! :month))))+ (testing "quarter"+ (is (= [["2022-04-01T00:00:00Z"]]+ (mid-year! :quarter))))+ (testing "year"+ (is (= [["2022-01-01T00:00:00Z"]]+ (mid-year! :year)))))+ (testing "extract"+ (testing "minute of hour"+ (is (= [[0]]+ (start-of-year! :minute-of-hour)))+ (is (= [[32]]+ (mid-year! :minute-of-hour)))+ (is (= [[59]]+ (end-of-year! :minute-of-hour))))+ (testing "hour of day"+ (is (= [[0]]+ (start-of-year! :hour-of-day)))+ (is (= [[6]]+ (mid-year! :hour-of-day)))+ (is (= [[23]]+ (end-of-year! :hour-of-day))))+ (testing "day of month"+ (is (= [[1]]+ (start-of-year! :day-of-month)))+ (is (= [[20]]+ (mid-year! :day-of-month)))+ (is (= [[31]]+ (end-of-year! :day-of-month))))+ (testing "day of year"+ (is (= [[1]]+ (start-of-year! :day-of-year)))+ (is (= [[171]]+ (mid-year! :day-of-year)))+ (is (= [[365]]+ (end-of-year! :day-of-year))))+ (testing "month of year"+ (is (= [[1]]+ (start-of-year! :month-of-year)))+ (is (= [[6]]+ (mid-year! :month-of-year)))+ (is (= [[12]]+ (end-of-year! :month-of-year))))+ (testing "quarter of year"+ (is (= [[1]]+ (start-of-year! :quarter-of-year)))+ (is (= [[2]]+ (mid-year! :quarter-of-year)))+ (is (= [[4]]+ (end-of-year! :quarter-of-year)))))))))(deftest clickhouse-temporal-bucketing-column-tz(mt/test-driver :clickhouse(mt/dataset temporal_bucketing_db- (defn- start-of-year! [unit]- (->> {:breakout [[:field %start_of_year {:temporal-unit unit}]]}- (mt/run-mbql-query temporal_bucketing_column_tz)- mt/rows))- (defn- mid-year! [unit]- (->> {:breakout [[:field %mid_of_year {:temporal-unit unit}]]}- (mt/run-mbql-query temporal_bucketing_column_tz)- mt/rows))- (defn- end-of-year! [unit]- (->> {:breakout [[:field %end_of_year {:temporal-unit unit}]]}- (mt/run-mbql-query temporal_bucketing_column_tz)- mt/rows))- (testing "truncate to"- (testing "minute"- (is (= [["2022-06-20T13:32:00Z"]]- (mid-year! :minute))))- (testing "hour"- (is (= [["2022-06-20T13:00:00Z"]]- (mid-year! :hour))))- (testing "day"- (is (= [["2022-06-20T07:00:00Z"]]- (mid-year! :day))))- (testing "month"- (is (= [["2022-06-01T00:00:00Z"]]- (mid-year! :month))))- (testing "quarter"- (is (= [["2022-04-01T00:00:00Z"]]- (mid-year! :quarter))))- (testing "year"- (is (= [["2022-01-01T00:00:00Z"]]- (mid-year! :year)))))- (testing "extract"- (testing "minute of hour"- (is (= [[0]]- (start-of-year! :minute-of-hour)))- (is (= [[32]]- (mid-year! :minute-of-hour)))- (is (= [[59]]- (end-of-year! :minute-of-hour))))- (testing "hour of day"- (is (= [[0]]- (start-of-year! :hour-of-day)))- (is (= [[6]]- (mid-year! :hour-of-day)))- (is (= [[23]]- (end-of-year! :hour-of-day))))- (testing "day of month"- (is (= [[1]]- (start-of-year! :day-of-month)))- (is (= [[20]]- (mid-year! :day-of-month)))- (is (= [[31]]- (end-of-year! :day-of-month))))- (testing "day of year"- (is (= [[1]]- (start-of-year! :day-of-year)))- (is (= [[171]]- (mid-year! :day-of-year)))- (is (= [[365]]- (end-of-year! :day-of-year))))- (testing "month of year"- (is (= [[1]]- (start-of-year! :month-of-year)))- (is (= [[6]]- (mid-year! :month-of-year)))- (is (= [[12]]- (end-of-year! :month-of-year))))- (testing "quarter of year"- (is (= [[1]]- (start-of-year! :quarter-of-year)))- (is (= [[2]]- (mid-year! :quarter-of-year)))- (is (= [[4]]- (end-of-year! :quarter-of-year))))))))+ (letfn [(start-of-year! [unit]+ (->> {:breakout [[:field %start_of_year {:temporal-unit unit}]]}+ (mt/run-mbql-query temporal_bucketing_column_tz)+ mt/rows))+ (mid-year! [unit]+ (->> {:breakout [[:field %mid_of_year {:temporal-unit unit}]]}+ (mt/run-mbql-query temporal_bucketing_column_tz)+ mt/rows))+ (end-of-year! [unit]+ (->> {:breakout [[:field %end_of_year {:temporal-unit unit}]]}+ (mt/run-mbql-query temporal_bucketing_column_tz)+ mt/rows))]+ (testing "truncate to"+ (testing "minute"+ (is (= [["2022-06-20T13:32:00Z"]]+ (mid-year! :minute))))+ (testing "hour"+ (is (= [["2022-06-20T13:00:00Z"]]+ (mid-year! :hour))))+ (testing "day"+ (is (= [["2022-06-20T07:00:00Z"]]+ (mid-year! :day))))+ (testing "month"+ (is (= [["2022-06-01T00:00:00Z"]]+ (mid-year! :month))))+ (testing "quarter"+ (is (= [["2022-04-01T00:00:00Z"]]+ (mid-year! :quarter))))+ (testing "year"+ (is (= [["2022-01-01T00:00:00Z"]]+ (mid-year! :year)))))+ (testing "extract"+ (testing "minute of hour"+ (is (= [[0]]+ (start-of-year! :minute-of-hour)))+ (is (= [[32]]+ (mid-year! :minute-of-hour)))+ (is (= [[59]]+ (end-of-year! :minute-of-hour))))+ (testing "hour of day"+ (is (= [[0]]+ (start-of-year! :hour-of-day)))+ (is (= [[6]]+ (mid-year! :hour-of-day)))+ (is (= [[23]]+ (end-of-year! :hour-of-day))))+ (testing "day of month"+ (is (= [[1]]+ (start-of-year! :day-of-month)))+ (is (= [[20]]+ (mid-year! :day-of-month)))+ (is (= [[31]]+ (end-of-year! :day-of-month))))+ (testing "day of year"+ (is (= [[1]]+ (start-of-year! :day-of-year)))+ (is (= [[171]]+ (mid-year! :day-of-year)))+ (is (= [[365]]+ (end-of-year! :day-of-year))))+ (testing "month of year"+ (is (= [[1]]+ (start-of-year! :month-of-year)))+ (is (= [[6]]+ (mid-year! :month-of-year)))+ (is (= [[12]]+ (end-of-year! :month-of-year))))+ (testing "quarter of year"+ (is (= [[1]]+ (start-of-year! :quarter-of-year)))+ (is (= [[2]]+ (mid-year! :quarter-of-year)))+ (is (= [[4]]+ (end-of-year! :quarter-of-year)))))))))(deftest clickhouse-uses-report-timezone-bucketing-source-query-test(mt/test-driver :clickhousediff --git a/modules/drivers/snowflake/src/metabase/driver/snowflake.clj b/modules/drivers/snowflake/src/metabase/driver/snowflake.cljindex 2cffdc5b6d7..3279f1ce5f8 100644--- a/modules/drivers/snowflake/src/metabase/driver/snowflake.clj+++ b/modules/drivers/snowflake/src/metabase/driver/snowflake.clj@@ -38,7 +38,7 @@[metabase.util.json :as json][metabase.util.log :as log][metabase.util.malli :as mu]- [metabase.util.performance :refer [mapv not-empty select-keys some]]+ [metabase.util.performance :as perf :refer [mapv not-empty select-keys some]][ring.util.codec :as codec])(:import(java.io File)@@ -671,8 +671,8 @@[driver db-id table-name column-definitions & args];; Snowflake doesn't support adding multiple columns in one statement, so add them one at a time(let [add-column! (get-method driver/add-columns! :sql-jdbc)]- (doseq [[column definition] column-definitions]- (apply add-column! driver db-id table-name {column definition} args))))+ (perf/run! (fn [[column definition]] (apply add-column! driver db-id table-name {column definition} args))+ column-definitions)))(defmethod driver/allowed-promotions :snowflake[_driver]diff --git a/src/metabase/api/macros.clj b/src/metabase/api/macros.cljindex fa845ac017c..2cc7d516b93 100644--- a/src/metabase/api/macros.clj+++ b/src/metabase/api/macros.clj@@ -383,6 +383,11 @@(throw (ex-info (format "Unable to parse defendpoint args: %s" (s/explain-str ::defendpoint args)){:args args:error (s/explain-data ::defendpoint args)})))+ ;; Otherwise the schema becomes two discarded body forms and the response is never validated.+ (when (= :- (first (:body conformed)))+ (throw (ex-info (str "defendpoint response schema must come right after the route, as in "+ "(defendpoint :get \"/route\" :- schema docstring params & body)")+ {:args args})))(as-> conformed conformed(update conformed :params parse-params)(update conformed :route parse-route conformed)diff --git a/src/metabase/app_db/custom_migrations.clj b/src/metabase/app_db/custom_migrations.cljindex 200525e0256..72fa44ed327 100644--- a/src/metabase/app_db/custom_migrations.clj+++ b/src/metabase/app_db/custom_migrations.clj@@ -46,8 +46,7 @@(liquibase Scope)(liquibase.change Change)(liquibase.change.custom CustomTaskChange CustomTaskRollback)- (liquibase.exception ValidationErrors)- (liquibase.util BooleanUtil)))+ (liquibase.exception ValidationErrors)))(set! *warn-on-reflection* true)@@ -58,7 +57,7 @@The same problem has been fixed for forward changes in Liquibasebut for rollback it has not."[]- (BooleanUtil/isTrue (.get (Scope/getCurrentScope) Change/SHOULD_EXECUTE true)))+ (.equals Boolean/TRUE (.get (Scope/getCurrentScope) Change/SHOULD_EXECUTE true)))(defmacro define-reversible-migration"Define a reversible custom migration. Both the forward and reverse migrations are defined using the same structure,diff --git a/src/metabase/app_db/liquibase.clj b/src/metabase/app_db/liquibase.cljindex c60bf174fdd..29d75672779 100644--- a/src/metabase/app_db/liquibase.clj+++ b/src/metabase/app_db/liquibase.clj@@ -58,7 +58,7 @@;; output stream to the null output stream(doto ^liquibase.ui.ConsoleUIService (.getUI (Scope/getCurrentScope));; we can't use `java.io.OutputStream/nullOutputStream` here because it's not available on Java 8- (.setOutputStream (java.io.PrintStream. (org.apache.commons.io.output.NullOutputStream.))))+ (.setOutputStream (java.io.PrintStream. org.apache.commons.io.output.NullOutputStream/INSTANCE)));; Disable phoning home to Liquibase analytics (since 4.28)(System/setProperty "liquibase.analytics.enabled" "false")diff --git a/src/metabase/channel/impl/email.clj b/src/metabase/channel/impl/email.cljindex 716d7485f05..39aba885aaa 100644--- a/src/metabase/channel/impl/email.clj+++ b/src/metabase/channel/impl/email.clj@@ -4,7 +4,8 @@[buddy.core.hash :as buddy-hash][clojure.java.io :as io][clojure.string :as str]- [hiccup.core :refer [h html]]+ [hiccup.core :refer [html]]+ [hiccup.util :as hiccup.util][medley.core :as m][metabase.analytics-interface.core :as analytics][metabase.analytics.core :as analytics.core]@@ -120,7 +121,7 @@heading-text (:text part)style (style/style (if (seq inline-params) {:margin-bottom "4px"} {}))];; hiccup 1 doesn't escape strings and :content reaches `{{{computed.dashboard_content}}}` as-is- {:content (str (html [:h2 {:style style} (h heading-text)])+ {:content (str (html [:h2 {:style style} (hiccup.util/escape-html heading-text)])rendered-params)}):tab-title{:content (markdown/process-markdown (format "# %s\n---" (:text part)) :html (system/site-url))}))diff --git a/src/metabase/channel/render/body.clj b/src/metabase/channel/render/body.cljindex 118c4b3fc98..b830a6f3f3e 100644--- a/src/metabase/channel/render/body.clj+++ b/src/metabase/channel/render/body.clj@@ -2,7 +2,7 @@(:require[clojure.string :as str][flatland.ordered.map :as ordered-map]- [hiccup.core :refer [h]]+ [hiccup.util :as hiccup.util][medley.core :as m][metabase.appearance.core :as appearance][metabase.channel.render.image-bundle :as image-bundle]@@ -232,7 +232,7 @@viz-settings)))))(defn- strong-limit-text [number]- [:strong {:style (style/style {:color style/color-gray-3})} (h (formatter/format-scalar-number number))])+ [:strong {:style (style/style {:color style/color-gray-3})} (hiccup.util/escape-html (formatter/format-scalar-number number))])(defn- render-truncation-warning[row-limit row-count]@@ -381,7 +381,7 @@bg (get cell-colors [r c])][(if (or header? label?) :th :td){:style (style/style (style/pivot-cell-style header? label? first-col? bg))}- (h (pivot-cell->str cell))]))+ (hiccup.util/escape-html (pivot-cell->str cell))]))row)])rows)]]))@@ -591,12 +591,12 @@[label value label-style value-style last?](let [border {:border-bottom (if last? 0 style/object-detail-border)}][:tr- [:td {:style (style/style label-style border)} (h label)]+ [:td {:style (style/style label-style border)} (hiccup.util/escape-html label)][:td {:style (style/style value-style border)}(if (nil? value);; Match the live viz: missing values show a muted "Empty" placeholder rather than a blank cell.[:span {:style (style/style (style/object-detail-empty-value-style))} (tru "Empty")]- (h value))]]))+ (hiccup.util/escape-html value))]]))(mu/defmethod render :object :- ::RenderedPartCard[_chart-type@@ -764,7 +764,7 @@:content[:div {:style (style/style (style/scalar-style color))}- (h value)]+ (hiccup.util/escape-html value)]:render/text (str value)}))(defn- series-cards-with-data@@ -1076,7 +1076,7 @@{:attachments nil:content [:div[:div {:style (style/style (style/scalar-style))}- (h value)]+ (hiccup.util/escape-html value)][:p {:style (style/style {:color style/color-text-medium:font-size :16px:font-weight 700@@ -1088,7 +1088,7 @@{:attachments nil:content [:div[:div {:style (style/style (style/scalar-style))}- (h last-value)]+ (hiccup.util/escape-html last-value)][:p {:style (style/style {:color style/color-text-medium:font-size :16px:font-weight 700diff --git a/src/metabase/channel/render/card.clj b/src/metabase/channel/render/card.cljindex 3f579c9408b..4710d63731a 100644--- a/src/metabase/channel/render/card.clj+++ b/src/metabase/channel/render/card.clj@@ -1,6 +1,6 @@(ns metabase.channel.render.card(:require- [hiccup.core :refer [h]]+ [hiccup.util :as hiccup.util][metabase.channel.render.body :as body][metabase.channel.render.image-bundle :as image-bundle][metabase.channel.render.markdown :as markdown]@@ -21,7 +21,7 @@(defn- card-href[card](when-let [card-id (u/id card)]- (h (urls/card-url card-id))))+ (hiccup.util/escape-html (urls/card-url card-id))))(mu/defn- make-title-if-needed :- [:maybe ::body/RenderedPartCard][render-type :- ::body/render-type@@ -49,7 +49,7 @@:rel "noopener noreferrer"}(not (:channel.render/disable-links? options))(assoc :href title-href))- (h card-name)]]+ (hiccup.util/escape-html card-name)]][:td {:style (style/style {:text-align :right})}(when (:channel.render/include-buttons? options)[:img {:style (style/style {:width :16px})diff --git a/src/metabase/channel/render/js/graal.clj b/src/metabase/channel/render/js/graal.cljindex d309522ad7e..3c8b3f8d94a 100644--- a/src/metabase/channel/render/js/graal.clj+++ b/src/metabase/channel/render/js/graal.clj@@ -24,7 +24,8 @@[metabase.util.pool :as u.pool])(:import(io.aleph.dirigiste Pool)- (org.graalvm.polyglot Context Engine HostAccess Source Value)))+ (org.graalvm.polyglot Context Engine HostAccess Source Value)+ (org.graalvm.polyglot.io IOAccess)))(set! *warn-on-reflection* true)@@ -56,7 +57,7 @@(allowHostClassLookup no-host-class-lookup)(out System/out)(err System/err)- (allowIO false)+ (allowIO IOAccess/NONE)(build))))(defn load-js-stringdiff --git a/src/metabase/channel/render/js/svg.clj b/src/metabase/channel/render/js/svg.cljindex 2bbea5eb67d..06af6725560 100644--- a/src/metabase/channel/render/js/svg.clj+++ b/src/metabase/channel/render/js/svg.clj@@ -35,7 +35,7 @@(apply conj (pop s);; reverse the nodes for the stack so it goes down first child first(map #(.item nodelist %) (reverse (range length)))))]- (reduce (fn [node f] (f node)) node post-fns)+ (run! #(% node) post-fns)(recur s'))))svg-document)diff --git a/src/metabase/channel/render/markdown.clj b/src/metabase/channel/render/markdown.cljindex e9a9345787d..72f6adaa649 100644--- a/src/metabase/channel/render/markdown.clj+++ b/src/metabase/channel/render/markdown.clj@@ -114,8 +114,7 @@LinkRef(to-clojure [this]{:tag (node-to-tag this)- :attrs {:reference (-> (.getDocument this)- (.get Parser/REFERENCES)+ :attrs {:reference (-> (.get Parser/REFERENCES (.getDocument this))(get (u/lower-case-en (str (.getReference this))))to-clojure)}:content (convert-children this)})@@ -123,8 +122,7 @@ImageRef(to-clojure [this]{:tag (node-to-tag this)- :attrs {:reference (-> (.getDocument this)- (.get Parser/REFERENCES)+ :attrs {:reference (-> (.get Parser/REFERENCES (.getDocument this))(get (u/lower-case-en (str (.getReference this))))to-clojure)}:content (convert-children this)})@@ -421,9 +419,7 @@and Markdown rendering on the frontend."[^Node node](and (instance? LinkRef node)- (-> (.getDocument node)- (.get Parser/REFERENCES)- empty?)))+ (empty? (.get Parser/REFERENCES (.getDocument node)))))(def ^:private renderer"An instance of a Flexmark HTML renderer"diff --git a/src/metabase/channel/render/table.clj b/src/metabase/channel/render/table.cljindex ba7861cddd3..d1d5f779af8 100644--- a/src/metabase/channel/render/table.clj+++ b/src/metabase/channel/render/table.clj@@ -1,7 +1,7 @@(ns metabase.channel.render.table(:require[clojure.string :as str]- [hiccup.core :refer [h]]+ [hiccup.util :as hiccup.util][medley.core :as m][metabase.channel.render.js.color :as js.color][metabase.channel.render.style :as style]@@ -84,7 +84,7 @@{:font-weight 400:color style/color-text-light}):title "Row Index"}- (h "#")])+ (hiccup.util/escape-html "#")])(map-indexed(fn [idx header-cell](let [title (get column-names idx)@@ -95,7 +95,7 @@{:min-width :42px}(get col->styles (:name col))):title title}- (truncate-text (h title))]))+ (truncate-text (hiccup.util/escape-html title))]))row)]])(defn calculate-pct-widths@@ -145,7 +145,7 @@bar-width] (calculate-pct-widths cell-width)][:table {:style (style/style {:width (str cell-width "px") :border "0" :border-collapse "collapse"})}[:tr- [:td {:style (style/style {:width label-width :vertical-align "middle" :padding-right "10px"})} (h val)]+ [:td {:style (style/style {:width label-width :vertical-align "middle" :padding-right "10px"})} (hiccup.util/escape-html val)][:td {:style (style/style {:width bar-width :vertical-align "middle" :padding "0"})}[:table {:style (style/style {:width "100%" :border-collapse "collapse"})}[:tr@@ -183,7 +183,7 @@:background-color (style/mb-primary-color):border-radius "3px"})}][:td {:style (style/style {:width (format "%s%%" pct-left) :padding "0"})}]]]]])]]]]])- (h val)))+ (hiccup.util/escape-html val)))(defn- image-url?"Whether a `view_as: \"image\"` cell may become an `<img src>`: only http(s), never an attacker-supplied@@ -242,11 +242,11 @@;; View as image(and (= (get col-settings ::mb.viz/view-as) "image")(image-url? cell))- [:img {:src (h cell)+ [:img {:src (hiccup.util/escape-html cell):style (style/style style/view-as-img-style)}]:else- (h cell))]))]))])+ (hiccup.util/escape-html cell))]))]))])(defn- get-min-width"Get the min width for a column with text wrapping enabled. In the happy path, column widths are supplied in viz settingsdiff --git a/src/metabase/channel/render/util.clj b/src/metabase/channel/render/util.cljindex e8b250f24f9..f81d2ad68f6 100644--- a/src/metabase/channel/render/util.clj+++ b/src/metabase/channel/render/util.clj@@ -1,7 +1,8 @@(ns metabase.channel.render.util(:require[clojure.string :as str]- [hiccup.core :refer [h html]]+ [hiccup.core :refer [html]]+ [hiccup.util :as hiccup.util][metabase.channel.render.style :as style][metabase.parameters.shared :as shared.params][metabase.system.core :as system]@@ -244,6 +245,6 @@{:style (style/style {:margin-bottom "4px"})}[:span {:style (style/style {:color style/color-text-dark:padding-right "8px"})}- (h name)]+ (hiccup.util/escape-html name)][:span {:style (style/style {:color style/color-text-medium})}- (h value-str)]])])))+ (hiccup.util/escape-html value-str)]])])))diff --git a/src/metabase/cloud_migration/models/cloud_migration.clj b/src/metabase/cloud_migration/models/cloud_migration.cljindex acc270bbcdc..83acb24c62e 100644--- a/src/metabase/cloud_migration/models/cloud_migration.clj+++ b/src/metabase/cloud_migration/models/cloud_migration.clj@@ -137,7 +137,9 @@Returns a sub-stream that should be used inside with-open."[^InputStream stream start end](.skip stream start)- (BoundedInputStream. stream (- end start)))+ (.get (doto (BoundedInputStream/builder)+ (.setInputStream stream)+ (.setMaxCount (- end start)))))(defn- put-file"Put file, whole or from start to end, on url, reporting on-progress. Retries up to 3 times."diff --git a/src/metabase/documents/markdown.clj b/src/metabase/documents/markdown.cljindex 85fd3e29bc1..260f67271e4 100644--- a/src/metabase/documents/markdown.clj+++ b/src/metabase/documents/markdown.clj@@ -1134,14 +1134,15 @@(let [start (.length sb)child-extents(if (container-types type)- (do (.append sb ^String (case type- "resizeNode" (resize-fence attrs)- "flexContainer" (flex-fence attrs)- "supportingText" "::: supporting"))- (.append sb "\n")- (let [extents (emit-blocks! ctx content)]- (.append sb "\n:::")- extents))+ (let [^String fence (case type+ "resizeNode" (resize-fence attrs)+ "flexContainer" (flex-fence attrs)+ "supportingText" "::: supporting")]+ (.append sb fence)+ (.append sb "\n")+ (let [extents (emit-blocks! ctx content)]+ (.append sb "\n:::")+ extents))(if-let [body (block-body node)](do (.append sb ^String body) nil)(throw (ex-info (format "Cannot serialize unknown block node type %s to Markdown." (pr-str type))diff --git a/src/metabase/driver/h2.clj b/src/metabase/driver/h2.cljindex 656f928d2f3..dffcb75e784 100644--- a/src/metabase/driver/h2.clj+++ b/src/metabase/driver/h2.clj@@ -720,8 +720,8 @@[driver db-id table-name column-definitions & opts];; H2 doesn't support altering multiple columns at a time, so we break it up into individual ALTER TABLE statements(let [f (get-method driver/alter-table-columns! :sql-jdbc)]- (doseq [[k v] column-definitions]- (apply f driver db-id table-name {k v} opts))))+ (perf/run! (fn [[k v]] (apply f driver db-id table-name {k v} opts))+ column-definitions)))(defmethod driver/allowed-promotions :h2[_driver]diff --git a/src/metabase/geojson/api.clj b/src/metabase/geojson/api.cljindex 108fc92287d..15e991dc21f 100644--- a/src/metabase/geojson/api.clj+++ b/src/metabase/geojson/api.clj@@ -108,7 +108,7 @@"Reads the provided URL and responds with the contents as a stream."[url respond](with-open [^BufferedReader reader (url->reader url)- is (ReaderInputStream. reader)]+ is (.get (doto (ReaderInputStream/builder) (.setReader reader)))](respond (-> (response/response is)(response/content-type "application/json")))))diff --git a/src/metabase/logger/core.clj b/src/metabase/logger/core.cljindex e01ed43b565..56eec5e6460 100644--- a/src/metabase/logger/core.clj+++ b/src/metabase/logger/core.clj@@ -20,7 +20,7 @@(org.apache.logging.log4j LogManager Level)(org.apache.logging.log4j.core Appender LogEvent Logger LoggerContext)(org.apache.logging.log4j.core.appender AbstractAppender FileAppender OutputStreamAppender)- (org.apache.logging.log4j.core.config AbstractConfiguration Configuration LoggerConfig)))+ (org.apache.logging.log4j.core.config AbstractConfiguration AppenderRef Configuration LoggerConfig Property)))(set! *warn-on-reflection* true)@@ -123,7 +123,7 @@(doto (FileAppender/newBuilder)(.setName "shared-appender-file")(.setLayout layout)- (.withFileName (.getPath out)))))+ (.setFileName (.getPath out)))))java.io.OutputStream(make-appender [^java.io.OutputStream out layout]@@ -224,17 +224,16 @@{:post [(exact-ns-logger a-namespace)]}(when-not (exact-ns-logger a-namespace)(let [parent-logger (effective-ns-logger a-namespace)- new-logger (LoggerConfig/createLogger- (.isAdditive parent-logger)- (.getLevel parent-logger)- (logger-name a-namespace)- (str (.isIncludeLocation parent-logger))- ^"[Lorg.apache.logging.log4j.core.config.AppenderRef;"- (into-array org.apache.logging.log4j.core.config.AppenderRef (.getAppenderRefs parent-logger))- ^"[Lorg.apache.logging.log4j.core.config.Property;"- (into-array org.apache.logging.log4j.core.config.Property (.getPropertyList parent-logger))- (configuration)- (.getFilter parent-logger))]+ new-logger (.build+ (doto (LoggerConfig/newBuilder)+ (.setAdditivity (.isAdditive parent-logger))+ (.setLevel (.getLevel parent-logger))+ (.setLoggerName (logger-name a-namespace))+ (.setIncludeLocation (str (.isIncludeLocation parent-logger)))+ (.setRefs (into-array AppenderRef (.getAppenderRefs parent-logger)))+ (.setProperties (into-array Property (.getPropertyList parent-logger)))+ (.setConfig (configuration))+ (.setFilter (.getFilter parent-logger))))];; copy the appenders from the parent logger, e.g. the [[metabase.logger/metabase-appender]](doseq [[_name ^Appender appender] (.getAppenders parent-logger)](.addAppender new-logger appender (.getLevel new-logger) (.getFilter new-logger)))diff --git a/src/metabase/metabot/self/bedrock.clj b/src/metabase/metabot/self/bedrock.cljindex fe9e46bf535..aa157340423 100644--- a/src/metabase/metabot/self/bedrock.clj+++ b/src/metabase/metabot/self/bedrock.clj@@ -74,12 +74,15 @@:status-code 403}cause))+(defonce ^:private default-credentials-provider+ (delay (.build (DefaultCredentialsProvider/builder))))+(defn- chain-credentials"Credentials resolved from the AWS SDK default provider chain- (https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/credentials-chain.html). The SDK's shared- chain caches what it resolves, so short-lived role credentials rotate without a restart."+ (https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/credentials-chain.html). The chain is built+ once and caches what it resolves, so short-lived role credentials rotate without a restart."^AwsCredentialsIdentity []- (.resolveCredentials (DefaultCredentialsProvider/create)))+ (.resolveCredentials ^DefaultCredentialsProvider @default-credentials-provider))(defn- aws-identity"The AWS credentials identity to sign with: the connection's access key pair, carrying the session token when onediff --git a/src/metabase/notification/events/notification.clj b/src/metabase/notification/events/notification.cljindex 48e3ceab7c5..f786be79d79 100644--- a/src/metabase/notification/events/notification.clj+++ b/src/metabase/notification/events/notification.clj@@ -33,7 +33,8 @@(if (map? x)(reduce-kv(fn [acc k {:keys [key model] :as _hydrate-prop}]- (assoc acc key (notification.db/instance model (get x k))))+ (cond-> acc+ (contains? x k) (assoc key (notification.db/instance model (get x k)))))xhydrates)x)))))}}}))diff --git a/src/metabase/notification/send.clj b/src/metabase/notification/send.cljindex 672955310a2..9e7433eeec7 100644--- a/src/metabase/notification/send.clj+++ b/src/metabase/notification/send.clj@@ -19,7 +19,7 @@[toucan2.core :as t2])(:import(java.util.concurrent ArrayBlockingQueue Callable Executors ThreadPoolExecutor)- (org.apache.commons.lang3.concurrent BasicThreadFactory$Builder)+ (org.apache.commons.lang3.concurrent BasicThreadFactory)(org.quartz CronExpression)))(set! *warn-on-reflection* true)@@ -482,7 +482,7 @@(let [executor (Executors/newFixedThreadPoolpool-size(.build- (doto (BasicThreadFactory$Builder.)+ (doto (BasicThreadFactory/builder)(.namingPattern "send-notification-thread-pool-%d"))))shutdown-flag (java.util.concurrent.atomic.AtomicBoolean. false)start-worker! (fn []diff --git a/src/metabase/plugins/jdbc_proxy.clj b/src/metabase/plugins/jdbc_proxy.cljindex 756f9d280cb..6e1cc038f37 100644--- a/src/metabase/plugins/jdbc_proxy.clj+++ b/src/metabase/plugins/jdbc_proxy.clj@@ -63,7 +63,7 @@(log/debug (u/format-color 'cyan"Not creating proxy JDBC driver for class %s -- original driver was loaded by system ClassLoader"class-name))- (let [driver (proxy-driver (.newInstance klass))]+ (let [driver (proxy-driver (.newInstance (.getDeclaredConstructor klass (into-array Class [])) (object-array 0)))](log/debug (u/format-color 'blue "Registering JDBC proxy driver for %s..." class-name))(DriverManager/registerDriver driver);; deregister the non-proxy version of the driver so it doesn't try to handle our URLs. Most JDBC drivers registerdiff --git a/src/metabase/query_processor/middleware/auto_bucket_datetimes.clj b/src/metabase/query_processor/middleware/auto_bucket_datetimes.cljindex 258cd536947..edab22d52f4 100644--- a/src/metabase/query_processor/middleware/auto_bucket_datetimes.clj+++ b/src/metabase/query_processor/middleware/auto_bucket_datetimes.clj@@ -160,11 +160,6 @@field-id->type-info :- [:maybe ::column-id-or-name->type-info]](letfn [(datetime-but-not-time? [field-id](some-> field-id field-id->type-info date-or-datetime-clause?))- ;; Following function copies type extraction logic from [[unbucketed-fields->field-id->type-info]],- ;; to conform original schema.- (expression-opts->type-info [{:keys [base-type effective-type]}] :- ::column-id-or-name->type-info- {:base-type base-type- :effective-type (or effective-type base-type)})(wrap-clauses [x](match/replace x;; don't replace anything that's already bucketed or otherwise is not subject to autobucketing@@ -176,7 +171,10 @@[:field _opts (_id-or-name :guard datetime-but-not-time?)](lib/with-temporal-bucket &match :day)- [:expression (opts :guard (date-or-datetime-clause? (expression-opts->type-info opts))) _name]+ [:expression+ (opts :guard (date-or-datetime-clause? {:base-type (:base-type opts)+ :effective-type (:effective-type opts)}))+ _name](lib/with-temporal-bucket &match :day)))(rewrite-clause [stage clause-to-rewrite](m/update-existing stage clause-to-rewrite wrap-clauses))]diff --git a/src/metabase/query_processor/streaming/xlsx.clj b/src/metabase/query_processor/streaming/xlsx.cljindex 0b4d6ae2533..8023985e2e2 100644--- a/src/metabase/query_processor/streaming/xlsx.clj+++ b/src/metabase/query_processor/streaming/xlsx.clj@@ -426,8 +426,8 @@(when (isa? semantic_type :type/Coordinate)(try (formatter/format-geographic-coordinates semantic_type value);; Fallback to plain string value if it couldn't be parsed- (catch Exception _ value- value))))+ (catch Exception _+ value))))(defn- maybe-parse-temporal-value"The format-rows qp middleware formats rows into strings, which circumvents the formatting done in this namespace.@@ -442,8 +442,8 @@(string? value))(try (u.date/parse value);; Fallback to plain string value if it couldn't be parsed- (catch Exception _ value- value))))+ (catch Exception _+ value))));; ColumnHelper hack.;;@@ -764,5 +764,7 @@(try(spreadsheet/save-workbook-into-stream! os workbook)(finally- (.dispose ^SXSSFWorkbook workbook)- (.close os)))))))+ (try+ (.close ^SXSSFWorkbook workbook)+ (finally+ (.close os)))))))))diff --git a/src/metabase/server/streaming_response/thread_pool.clj b/src/metabase/server/streaming_response/thread_pool.cljindex 859ed681c44..868af82a49b 100644--- a/src/metabase/server/streaming_response/thread_pool.clj+++ b/src/metabase/server/streaming_response/thread_pool.clj@@ -3,7 +3,7 @@[metabase.config.core :as config])(:import(java.util.concurrent Executors ThreadPoolExecutor)- (org.apache.commons.lang3.concurrent BasicThreadFactory$Builder)))+ (org.apache.commons.lang3.concurrent BasicThreadFactory)))(set! *warn-on-reflection* true)@@ -16,7 +16,7 @@(delay(Executors/newFixedThreadPool thread-pool-max-size(.build- (doto (BasicThreadFactory$Builder.)+ (doto (BasicThreadFactory/builder)(.namingPattern "streaming-response-thread-pool-%d");; Daemon threads do not block shutdown of the JVM(.daemon true))))))diff --git a/src/metabase/settings/models/setting.clj b/src/metabase/settings/models/setting.cljindex 81707f3c457..513a35f502e 100644--- a/src/metabase/settings/models/setting.clj+++ b/src/metabase/settings/models/setting.clj@@ -1499,9 +1499,9 @@setting-definition-symbol (gensym "setting-")]`(let [setting-options# (merge (merge-base ~options) ~setting-metadata)~setting-definition-symbol (register-setting! setting-options#)]- ~(when maybe-i18n-exception- `(when (#'requires-i18n? ~setting-definition-symbol)- (throw ~maybe-i18n-exception)))+ ~@(when maybe-i18n-exception+ [`(when (#'requires-i18n? ~setting-definition-symbol)+ (throw ~maybe-i18n-exception))])(-> (def ~setting-getter-fn-symbol (setting-fn :getter ~setting-definition-symbol))(alter-meta! merge (setting-fn-metadata :getter ~setting-definition-symbol)));; unfortunately we can't evaluate this condition at compile time, as the options might contain runtime forms.diff --git a/src/metabase/sql_tools/macaw/core.clj b/src/metabase/sql_tools/macaw/core.cljindex f214777a2b6..ad89fd0e2f2 100644--- a/src/metabase/sql_tools/macaw/core.clj+++ b/src/metabase/sql_tools/macaw/core.clj@@ -180,7 +180,7 @@(defmethod sql-tools/add-into-clause-impl :macaw[_parser driver sql table-name](let [^net.sf.jsqlparser.statement.select.Select parsed-query (parsed-query sql driver)- ^net.sf.jsqlparser.statement.select.PlainSelect select-body (.getSelectBody parsed-query)]+ ^net.sf.jsqlparser.statement.select.PlainSelect select-body (.getPlainSelect parsed-query)](.setIntoTables select-body [(net.sf.jsqlparser.schema.Table. ^String table-name)])(str parsed-query)))diff --git a/src/metabase/task_history/api.clj b/src/metabase/task_history/api.cljindex 158b06073ae..c3877833e26 100644--- a/src/metabase/task_history/api.clj+++ b/src/metabase/task_history/api.clj@@ -52,15 +52,11 @@;;; TODO -- this is not necessarily a 'task history' thing and maybe belongs in the `task` module's API rather than;;; here... maybe a problem for another day.;;-;; TODO (Cam 2025-11-25) please add a response schema to this API endpoint, it makes it easier for our customers to-;; use our API + we will need it when we make auto-TypeScript-signature generation happen-;;-#_{:clj-kondo/ignore [:metabase/validate-defendpoint-has-response-schema]}-(api.macros/defendpoint :get "/unique-tasks"+(api.macros/defendpoint :get "/unique-tasks" :- [:vector string?]"Returns possibly empty vector of unique task names in alphabetical order. It is expected that number of uniquetasks is small, hence no need for pagination. If that changes this endpoint and function that powers it shouldreflect that."- [] :- [:vector string?]+ [](perms/check-has-application-permission :monitoring)(task-history/unique-tasks))diff --git a/src/metabase/upload/parsing.clj b/src/metabase/upload/parsing.cljindex 2055f82f93f..e0b08766344 100644--- a/src/metabase/upload/parsing.clj+++ b/src/metabase/upload/parsing.clj@@ -169,10 +169,10 @@;; returning the wrong number. We give each thread its own formatter per locale via ThreadLocal,;; so a thread reuses its copy across every cell instead of reallocating one per value.;; See https://linear.app/metabase/issue/GDGT-304-(let [us (number-format-thread-local (Locale. "en" "US"))- de (number-format-thread-local (Locale. "de" "DE"))- fr (number-format-thread-local (Locale. "fr" "FR"))- ch (number-format-thread-local (Locale. "de" "CH"))]+(let [us (number-format-thread-local (Locale/of "en" "US"))+ de (number-format-thread-local (Locale/of "de" "DE"))+ fr (number-format-thread-local (Locale/of "fr" "FR"))+ ch (number-format-thread-local (Locale/of "de" "CH"))](defn- parse-plain-number [number-separators s](let [has-parens? (re-matches #"\(.*\)" s)deparenthesized-s (str/replace s #"[()]" "")diff --git a/src/metabase/util.cljc b/src/metabase/util.cljcindex da0dbf05b86..137b832d45e 100644--- a/src/metabase/util.cljc+++ b/src/metabase/util.cljc@@ -485,7 +485,7 @@(round-to-decimals 2 35.5058998M) -> 35.51"^Double [^Integer decimal-place, ^Number number]{:pre [(integer? decimal-place) (number? number)]}- #?(:clj (double (.setScale (bigdec number) decimal-place BigDecimal/ROUND_HALF_UP))+ #?(:clj (double (.setScale (bigdec number) decimal-place java.math.RoundingMode/HALF_UP)):cljs (parse-double (.toFixed number decimal-place))))(defn real-number?@@ -1302,7 +1302,7 @@Returns the number of items processed."[proc reducible](let [cnt (volatile! 0)]- (reduce (fn [_ item] (vswap! cnt inc) (proc item)) nil reducible)+ (run! (fn [item] (vswap! cnt inc) (proc item)) reducible)@cnt))(defn generate-nano-iddiff --git a/src/metabase/util/connection.clj b/src/metabase/util/connection.cljindex 60ce72111c9..21c7acf7396 100644--- a/src/metabase/util/connection.clj+++ b/src/metabase/util/connection.clj@@ -17,7 +17,7 @@(let [field (doto (.getDeclaredField com.mchange.v2.c3p0.C3P0Registry "classNamesToConnectionCustomizers")(.setAccessible true))](.put ^java.util.HashMap (.get field com.mchange.v2.c3p0.C3P0Registry)- (.getName klass) (.newInstance klass))))+ (.getName klass) (.newInstance (.getDeclaredConstructor klass (into-array Class [])) (object-array 0)))))(defn- consume-rset [^ResultSet rset cb](into {} (iterationdiff --git a/src/metabase/util/formatting/internal/numbers.clj b/src/metabase/util/formatting/internal/numbers.cljindex 5f29d7b2bef..24d8ea08dd1 100644--- a/src/metabase/util/formatting/internal/numbers.clj+++ b/src/metabase/util/formatting/internal/numbers.clj@@ -47,7 +47,7 @@(defn- active-locale [options](if (:locale options)- (Locale. (:locale options))+ (Locale/of (:locale options))(Locale/getDefault)))(defn- number-formatter-for-options-baselinediff --git a/src/metabase/util/i18n/plural.clj b/src/metabase/util/i18n/plural.cljindex e34f275413c..b6ca905d19a 100644--- a/src/metabase/util/i18n/plural.clj+++ b/src/metabase/util/i18n/plural.clj@@ -5,6 +5,8 @@[clojure.core.memoize :as memoize][instaparse.core :as insta]))+(set! *warn-on-reflection* true)+(def ^:private plural-form-parser"This is a parser for the C-like syntax used to express pluralization rules in the Plural-Forms header intranslation files.@@ -94,7 +96,7 @@:and-expr #(to-int (and (to-bool %1) (to-bool %2))):or-expr #(to-int (or (to-bool %1) (to-bool %2))):ternary #(to-int (if (to-bool %1) %2 %3))- :integer #(Integer. ^String %)+ :integer #(Integer/valueOf ^String %):variable (constantly n):expr identity})diff --git a/src/metabase/util/malli.cljc b/src/metabase/util/malli.cljcindex 1b40e828315..da2361a6fd0 100644--- a/src/metabase/util/malli.cljc+++ b/src/metabase/util/malli.cljc@@ -2,7 +2,8 @@(:refer-clojure :exclude [fn defn defn- defmethod])(:require#?@(:clj- ([metabase.util.malli.fn :as mu.fn]+ ([metabase.util.malli.closed-schemas]+ [metabase.util.malli.fn :as mu.fn][metabase.util.malli.defn :as mu.defn][net.cgrand.macrovich :as macros][potemkin :as p]))diff --git a/src/metabase/util/match.clj b/src/metabase/util/match.cljindex 3709c11a35d..293336da985 100644--- a/src/metabase/util/match.clj+++ b/src/metabase/util/match.clj@@ -69,8 +69,17 @@(declare process-clauses)+(defn- strip-meta [expr]+ (if (instance? clojure.lang.IObj expr)+ (vary-meta expr dissoc :depends-on :vector-check)+ expr))+(defn- process-pattern [pattern value bindings conditions return]- (let [{:keys [parts rest-part predicate] :as parsed} (parse-pattern pattern)]+ (let [{:keys [parts rest-part predicate] :as parsed} (parse-pattern pattern)+ ;; The metadata on `value` is only for an equality condition to inherit its `:depends-on`.+ ;; Left on the emitted code, it would do nothing.+ value-meta (meta value)+ value (if (symbol? value) value (strip-meta value))](case (:type parsed):symbol (when-not (= (:symbol parsed) '_)(vswap! bindings conj [(:symbol parsed) value]))@@ -123,7 +132,7 @@(when (:length parsed)(vswap! conditions conj (with-meta (list `metabase.util.match.impl/count= s (:length parsed)){:depends-on s}))))- :equality (vswap! conditions conj (with-meta (list `= value (:value parsed)) (meta value)))+ :equality (vswap! conditions conj (with-meta (list `= value (:value parsed)) value-meta)):set (vswap! conditions conj (list (:value parsed) value)))))(defn- process-clause [[pattern ret] value-sym]@@ -136,11 +145,6 @@(defn- seq-contains? [coll item](some #(= % item) coll))-(defn- strip-meta [expr]- (if (instance? clojure.lang.IObj expr)- (vary-meta expr dissoc :depends-on :vector-check)- expr))-(defn- collect-common [bindings conditions](let [common-bindings (filter (fn [bind] (every? #(seq-contains? % bind) bindings))(first bindings))@@ -159,7 +163,7 @@(mapv (fn [conditions](->> conditions(remove #(seq-contains? common-conditions %))- strip-meta))))}))+ (mapv strip-meta)))))}))(defn- expand-conditions [combiner conditions body & [bool?]](case (count conditions)@@ -401,7 +405,7 @@processed (process-clause [clause true] '&match)]`(let [~'&match ~value~@(mapcat identity (:bindings processed))]- ~(expand-conditions `and (:conditions processed) true true))))+ ~(expand-conditions `and (mapv strip-meta (:conditions processed)) true true))))(defmacro matches?"Pattern matching macro for a single clause that returns `true` if the pattern matches, and `false` otherwise. Seediff --git a/src/metabase/warehouse_schema_rest/api/table.clj b/src/metabase/warehouse_schema_rest/api/table.cljindex 457bad4a40b..0116113fb9b 100644--- a/src/metabase/warehouse_schema_rest/api/table.clj+++ b/src/metabase/warehouse_schema_rest/api/table.clj@@ -127,13 +127,11 @@;; TODO (Cam 10/28/25) -- fix this endpoint so it uses kebab-case for query parameters for consistency with the rest;; of the REST API-;;-;; TODO (Cam 2025-11-25) please add a response schema to this API endpoint, it makes it easier for our customers to-;; use our API + we will need it when we make auto-TypeScript-signature generation happen-;;-#_{:clj-kondo/ignore [:metabase/validate-defendpoint-query-params-use-kebab-case- :metabase/validate-defendpoint-has-response-schema]}+#_{:clj-kondo/ignore [:metabase/validate-defendpoint-query-params-use-kebab-case]}(api.macros/defendpoint :get "/:id"+ ;; partial schema only+ :- [:map {:closed false}+ [:data_authority ::data-authority-read]]"Get `Table` with ID."{:scope api-scope/data-app}[{:keys [id]} :- [:map {:closed true}@@ -143,9 +141,6 @@[:include_editable_data_model {:optional true} [:maybe :boolean]]]_bodyrequest]- ;; partial schema only- :- [:map {:closed false}- [:data_authority ::data-authority-read]](some-> (data-apps/request-data-app request) (data-apps/check-table id))(let [api-perm-check-fn (if include_editable_data_modelschema.table/check-data-model-permsdiff --git a/test/metabase/agent_lib/representations/repair_test.clj b/test/metabase/agent_lib/representations/repair_test.cljindex d50f5da494f..2b6ac4a7fdf 100644--- a/test/metabase/agent_lib/representations/repair_test.clj+++ b/test/metabase/agent_lib/representations/repair_test.clj@@ -4156,12 +4156,12 @@(deftest join-alias-field-type-resolves-each-join-at-most-once-test(let [resolutions (fn [join-stages q]- (let [calls (atom 0)- resolve (mt/original-fn #'repr.resolve/resolve-query)]+ (let [calls (atom 0)+ resolve-query (mt/original-fn #'repr.resolve/resolve-query)](mt/with-dynamic-fn-redefs [repr.resolve/resolve-query (fn [mp query store](when (= join-stages (get query "stages"))(swap! calls inc))- (resolve mp query store))]+ (resolve-query mp query store))](repair* q))@calls))](testing "a join named only by already-typed by-name refs is resolved once, to check them"diff --git a/test/metabase/api/macros_test.clj b/test/metabase/api/macros_test.cljindex e391173af1d..32bfae18bf9 100644--- a/test/metabase/api/macros_test.clj+++ b/test/metabase/api/macros_test.clj@@ -178,6 +178,11 @@:query {:binding _query-params, :schema [:map {:closed true}]}}:body [(test)]})))+(deftest ^:parallel parse-args-misplaced-response-schema-test+ (testing "a response schema after the params is rejected instead of being dropped into the body"+ (is (thrown-with-msg? Exception #"response schema must come right after the route"+ (#'api.macros/parse-args '(:get "/test" "A test endpoint." [] :- [:vector :string] (test)))))))+(deftest ^:parallel decode-strips-undeclared-keys-test(testing "request decoding drops keys the schema does not name, so an open map cannot carry values downstream"(are [schema value expected] (= expecteddiff --git a/test/metabase/api_keys/schema_test.clj b/test/metabase/api_keys/schema_test.cljdeleted file mode 100644index e69de29bb2d..00000000000diff --git a/test/metabase/api_keys/schemas_test.clj b/test/metabase/api_keys/schemas_test.cljdeleted file mode 100644index e69de29bb2d..00000000000diff --git a/test/metabase/app_db/schema_migrations_test.clj b/test/metabase/app_db/schema_migrations_test.cljindex 11cbafae5f5..480bfdeb6a4 100644--- a/test/metabase/app_db/schema_migrations_test.clj+++ b/test/metabase/app_db/schema_migrations_test.clj@@ -46,7 +46,10 @@[metabase.util.encryption-test :as encryption-test][metabase.util.json :as json][metabase.warehouse-schema-overlay.core :as warehouse-schema-overlay]- [toucan2.core :as t2]))+ [toucan2.core :as t2])+ (:import+ (liquibase Scope)+ (liquibase.changelog ChangeLogHistoryServiceFactory)))(set! *warn-on-reflection* true)@@ -3353,7 +3356,7 @@:orderexecuted (+ last-order i 1):exectype "EXECUTED"})v59-ids))- (.resetAll (liquibase.changelog.ChangeLogHistoryServiceFactory/getInstance))+ (.resetAll ^ChangeLogHistoryServiceFactory (.getSingleton (Scope/getCurrentScope) ChangeLogHistoryServiceFactory))(migrate!)(testing "the stale v59 rows are gone and the existing column is adopted"(is (empty? (t2/select clog :id [:in v59-ids])))@@ -3594,7 +3597,7 @@:exectype "EXECUTED"})suffixes));; Liquibase caches the ran-changeset list per connection; drop it so the precondition sees the rows above.- (.resetAll (liquibase.changelog.ChangeLogHistoryServiceFactory/getInstance))+ (.resetAll ^ChangeLogHistoryServiceFactory (.getSingleton (Scope/getCurrentScope) ChangeLogHistoryServiceFactory))(migrate!)(is (= (repeat 4 "MARK_RAN")(map #(t2/select-one-fn :exectype clog :id (str "v64.2026-09-11" %)) suffixes)))diff --git a/test/metabase/app_db/schema_migrations_test/impl.clj b/test/metabase/app_db/schema_migrations_test/impl.cljindex d257ca08ed9..95934143844 100644--- a/test/metabase/app_db/schema_migrations_test/impl.clj+++ b/test/metabase/app_db/schema_migrations_test/impl.clj@@ -30,7 +30,7 @@[toucan2.core :as t2])(:import(liquibase LabelExpression)- (liquibase.changelog ChangeLogHistoryServiceFactory ChangeSet)+ (liquibase.changelog ChangeSet)(liquibase.changelog.filter ChangeSetFilter ChangeSetFilterResult)))(set! *warn-on-reflection* true)@@ -145,14 +145,12 @@id start-id end-id(if inclusive-end? "(inclusive)" "(exclusive)")accept?)- (ChangeSetFilterResult. accept? "decision according to range" (class this)))))]- change-log-service (.getChangeLogService (ChangeLogHistoryServiceFactory/getInstance) database)]+ (ChangeSetFilterResult. accept? "decision according to range" (class this)))))]](versions/ensure-version-tracking! conn database)(liquibase/with-scope-locked liquibase;; Calling .listUnrunChangeSets has the side effect of creating the Liquibase tables;; and initializing checksums so that they match the ones generated in production.(.listUnrunChangeSets liquibase nil (LabelExpression.))- (.generateDeploymentId change-log-service)(liquibase/update-with-change-log liquibase {:change-set-filters change-set-filters}))(mdb.test-util/split-legacy-majors-into-deployments! conn changelog-table))))diff --git a/test/metabase/auth_identity/provider_test.clj b/test/metabase/auth_identity/provider_test.cljindex fa727f9fa18..d7514960485 100644--- a/test/metabase/auth_identity/provider_test.clj+++ b/test/metabase/auth_identity/provider_test.clj@@ -59,16 +59,27 @@provider/provider-string->keywordprovider/provider-keyword->string))))))+;; A test provider that returns redirect+(auth-identity/derive! :provider/test-redirect ::provider/provider)++(methodical/defmethod provider/authenticate :provider/test-redirect+ [_provider _request]+ {:success? :redirect+ :redirect-url "https://example.com/oauth"+ :message "Redirecting to provider"})++;; A test provider that returns error+(auth-identity/derive! :provider/test-error ::provider/provider)++(methodical/defmethod provider/authenticate :provider/test-error+ [_provider _request]+ {:success? false+ :error :invalid-credentials+ :message "Invalid credentials"})+(deftest login!-default-implementation-test(testing "login! default implementation handles redirect responses"(testing "Returns redirect response unchanged when authenticate returns :redirect"- ;; Create a test provider that returns redirect- (auth-identity/derive! :provider/test-redirect ::provider/provider)- (methodical/defmethod provider/authenticate :provider/test-redirect- [_provider _request]- {:success? :redirect- :redirect-url "https://example.com/oauth"- :message "Redirecting to provider"})(let [result (provider/login! :provider/test-redirect{:device-info {:device_id "test" :ip_address "127.0.0.1"}})](is (= :redirect (:success? result)))@@ -78,13 +89,6 @@(is (nil? (:user result))))))(testing "login! default implementation handles failure responses"(testing "Returns error response unchanged when authenticate fails"- ;; Create a test provider that returns error- (auth-identity/derive! :provider/test-error ::provider/provider)- (methodical/defmethod provider/authenticate :provider/test-error- [_provider _request]- {:success? false- :error :invalid-credentials- :message "Invalid credentials"})(let [result (provider/login! :provider/test-error{:email "[email protected]":password "wrong"diff --git a/test/metabase/channel/render/table_test.clj b/test/metabase/channel/render/table_test.cljindex 5c6a9a3d388..2a21031a92c 100644--- a/test/metabase/channel/render/table_test.clj+++ b/test/metabase/channel/render/table_test.clj@@ -94,7 +94,7 @@find-table-bodycell-value->background-color)))))-(deftest header-truncation-test []+(deftest header-truncation-test(let [[normal-heading long-heading :as row] ["Count" (apply str (repeat 120 "A"))][normal-rendered long-rendered] (->> (#'table/render-table-head row {:row row} nil {} false)(tree-seq vector? rest)diff --git a/test/metabase/collections/models/collection_test.clj b/test/metabase/collections/models/collection_test.cljindex 70b128c1d8d..6cda6bc279d 100644--- a/test/metabase/collections/models/collection_test.clj+++ b/test/metabase/collections/models/collection_test.clj@@ -541,7 +541,7 @@(is (thrown-with-msg?clojure.lang.ExceptionInfo#"Invalid Collection location: path is invalid"- (with-collection-in-location [_ "/a/"]))))+ (with-collection-in-location [_ "/a/"] nil))))(testing "We should be able to INSERT a Collection with a *valid* location"(mt/with-temp [:model/Collection parent](with-collection-in-location [collection (collection/location-path parent)]@@ -563,7 +563,7 @@(is (thrown-with-msg?clojure.lang.ExceptionInfo#"Invalid Collection location: some or all ancestors do not exist"- (with-collection-in-location [_ (collection/location-path (nonexistent-collection-id))]))))+ (with-collection-in-location [_ (collection/location-path (nonexistent-collection-id))] nil))))(testing "Make sure we can't UPDATE a Collection to give it a non-existent ancestors"(mt/with-temp [:model/Collection collection](is (thrown-with-msg?@@ -3180,10 +3180,10 @@"Should throw exception when parent has dependents on child items")](is (= "Used by remote synced content." (ex-message ex))"Exception should have correct message")- (let [ex-data (ex-data ex)]- (is (= 400 (:status-code ex-data))+ (let [data (ex-data ex)]+ (is (= 400 (:status-code data))"Exception should have 400 status code")- (is (= #{{"Card" dep-card-id}} (set (ex-data :remote-synced-models)))+ (is (= #{{"Card" dep-card-id}} (set (data :remote-synced-models)))"Exception should contain remote-synced dependents"))))(testing "Collection is NOT archived when exception is thrown"(let [child-after (t2/select-one :model/Collection :id child-id)]diff --git a/test/metabase/collections_rest/api_test.clj b/test/metabase/collections_rest/api_test.cljindex 6357e881718..5eb46f05099 100644--- a/test/metabase/collections_rest/api_test.clj+++ b/test/metabase/collections_rest/api_test.clj@@ -4112,9 +4112,8 @@(testing "rasta cannot see the exploration"(let [resp (mt/user-http-request :rasta :get (str "collection/" (:id coll) "/items"))];; Either the collection itself is forbidden (403) or the items list omits the exploration.- (cond- (= 403 (:status-code resp)) (is true)- :else (is (not (some #(= (:id e) (:id %)) (filter #(= "exploration" (:model %)) (:data resp))))))))+ (is (or (= 403 (:status-code resp))+ (not (some #(= (:id e) (:id %)) (filter #(= "exploration" (:model %)) (:data resp))))))))(testing "after granting read, the exploration appears"(perms/grant-collection-read-permissions! (perms/all-users-group) coll)(let [items (exploration-items-in (:id coll) :user :rasta)]diff --git a/test/metabase/dashboards_rest/api_test.clj b/test/metabase/dashboards_rest/api_test.cljindex eb7463ff53f..c4abdc5c28a 100644--- a/test/metabase/dashboards_rest/api_test.clj+++ b/test/metabase/dashboards_rest/api_test.clj@@ -4905,114 +4905,115 @@(is (= ["A sian" "As"](mt/user-http-request :crowberto :get 200 (url list-param-id "A sian"))))))))+(defn- test-handle-broken-subscription-notification!+ [{:keys [disable-links? email-body-pattern match-email-body-pattern?]}]+ (let [param {:name "Source"+ :slug "source"+ :id "_SOURCE_PARAM_ID_"+ :type :string/=}]+ (mt/dataset test-data+ (mt/with-temp+ [:model/Card {card-id :id} {:name "Native card"+ :database_id (mt/id)+ :dataset_query {:database (mt/id)+ :type :query+ :query {:source-table (mt/id :people)+ :limit 5+ :fields [[:field (mt/id :people :id)+ {:base-type :type/BigInteger}]+ [:field (mt/id :people :name)+ {:base-type :type/Text}]+ [:field (mt/id :people :source)+ {:base-type :type/Text}]]}}+ :type :model}+ :model/Dashboard {dash-id :id+ dashboard-name :name} {:name "My Awesome Dashboard"+ :parameters [param]}+ :model/DashboardCard {dash-card-id :id} {:dashboard_id dash-id+ :card_id card-id+ :parameter_mappings [{:parameter_id "_SOURCE_PARAM_ID_"+ :card_id card-id+ :target [:dimension+ [:field (mt/id :people :source)+ {:base-type :type/Text}]]}]}++ :model/Pulse {bad-pulse-id :id} {:name "Bad Pulse"+ :dashboard_id dash-id+ :creator_id (mt/user->id :trashbird)+ :parameters [(assoc param :value ["Twitter", "Facebook"])]+ :disable_links disable-links?}+ :model/PulseCard _ {:pulse_id bad-pulse-id+ :card_id card-id+ :dashboard_card_id dash-card-id}+ :model/PulseChannel {pulse-channel-id :id} {:channel_type :email+ :pulse_id bad-pulse-id+ :enabled true}+ :model/PulseChannelRecipient _ {:pulse_channel_id pulse-channel-id+ :user_id (mt/user->id :rasta)}+ :model/PulseChannelRecipient _ {:pulse_channel_id pulse-channel-id+ :user_id (mt/user->id :crowberto)}+ ;; Broken slack pulse+ :model/Pulse {bad-slack-pulse-id :id} {:name "Bad Slack Pulse"+ :dashboard_id dash-id+ :creator_id (mt/user->id :trashbird)+ :parameters [(assoc param :value ["LinkedIn"])]+ :disable_links disable-links?}+ :model/PulseCard _ {:pulse_id bad-slack-pulse-id+ :card_id card-id+ :dashboard_card_id dash-card-id}+ :model/PulseChannel _ {:channel_type :slack+ :pulse_id bad-slack-pulse-id+ :details {:channel "#my-channel"}+ :enabled true}+ ;; Non broken pulse+ :model/Pulse {good-pulse-id :id} {:name "Good Pulse"+ :dashboard_id dash-id+ :creator_id (mt/user->id :trashbird)}+ :model/PulseCard _ {:pulse_id good-pulse-id+ :card_id card-id+ :dashboard_card_id dash-card-id}+ :model/PulseChannel {good-pulse-channel-id :id} {:channel_type :email+ :pulse_id good-pulse-id+ :enabled true}+ :model/PulseChannelRecipient _ {:pulse_channel_id good-pulse-channel-id+ :user_id (mt/user->id :rasta)}+ :model/PulseChannelRecipient _ {:pulse_channel_id good-pulse-channel-id+ :user_id (mt/user->id :crowberto)}]+ (testing "The pulses are active"+ (is (false? (t2/select-one-fn :archived :model/Pulse bad-pulse-id)))+ (is (false? (t2/select-one-fn :archived :model/Pulse good-pulse-id))))+ (mt/with-fake-inbox+ (let [{:keys [parameters]} (dashboard-response (mt/user-http-request+ :rasta :put 200 (str "dashboard/" dash-id)+ {:parameters []}))+ title (format "Subscription to %s removed" dashboard-name)+ ;; Keep only the relevant messages. If not, you might get some other side-effecting email, such+ ;; as "We've Noticed a New Metabase Login, Rasta".+ inbox (update-vals+ @mt/inbox+ (fn [messages]+ (filterv (comp #{title} :subject) messages)))+ emails-received? (fn [recipient-email]+ (testing "The first email was received"+ (is (true? (some-> (get-in inbox [recipient-email 0 :body 0 :content])+ (str/includes? title)))))+ (testing "The second email (about the broken slack pulse) was received"+ (is (= match-email-body-pattern? (some-> (get-in inbox [recipient-email 1 :body 0 :content])+ (str/includes? email-body-pattern))))))]+ (testing "The dashboard parameters were removed"+ (is (empty? parameters)))+ (testing "The broken pulse was archived"+ (is (true? (t2/select-one-fn :archived :model/Pulse bad-pulse-id))))+ (testing "The unbroken pulse is still active"+ (is (false? (t2/select-one-fn :archived :model/Pulse good-pulse-id))))+ (testing "The dashboard and pulse creators were emailed about the removed pulse"+ (is (= #{"[email protected]" "[email protected]"}+ (set (keys inbox)))))+ (testing "Notification emails were sent to the dashboard and pulse creators"+ (emails-received? "[email protected]")+ (emails-received? "[email protected]"))))))))+(deftest handle-broken-subscriptions-due-to-bad-parameters-test- (defn- test-handle-broken-subscription-notification!- [{:keys [disable-links? email-body-pattern match-email-body-pattern?]}]- (let [param {:name "Source"- :slug "source"- :id "_SOURCE_PARAM_ID_"- :type :string/=}]- (mt/dataset test-data- (mt/with-temp- [:model/Card {card-id :id} {:name "Native card"- :database_id (mt/id)- :dataset_query {:database (mt/id)- :type :query- :query {:source-table (mt/id :people)- :limit 5- :fields [[:field (mt/id :people :id)- {:base-type :type/BigInteger}]- [:field (mt/id :people :name)- {:base-type :type/Text}]- [:field (mt/id :people :source)- {:base-type :type/Text}]]}}- :type :model}- :model/Dashboard {dash-id :id- dashboard-name :name} {:name "My Awesome Dashboard"- :parameters [param]}- :model/DashboardCard {dash-card-id :id} {:dashboard_id dash-id- :card_id card-id- :parameter_mappings [{:parameter_id "_SOURCE_PARAM_ID_"- :card_id card-id- :target [:dimension- [:field (mt/id :people :source)- {:base-type :type/Text}]]}]}-- :model/Pulse {bad-pulse-id :id} {:name "Bad Pulse"- :dashboard_id dash-id- :creator_id (mt/user->id :trashbird)- :parameters [(assoc param :value ["Twitter", "Facebook"])]- :disable_links disable-links?}- :model/PulseCard _ {:pulse_id bad-pulse-id- :card_id card-id- :dashboard_card_id dash-card-id}- :model/PulseChannel {pulse-channel-id :id} {:channel_type :email- :pulse_id bad-pulse-id- :enabled true}- :model/PulseChannelRecipient _ {:pulse_channel_id pulse-channel-id- :user_id (mt/user->id :rasta)}- :model/PulseChannelRecipient _ {:pulse_channel_id pulse-channel-id- :user_id (mt/user->id :crowberto)}- ;; Broken slack pulse- :model/Pulse {bad-slack-pulse-id :id} {:name "Bad Slack Pulse"- :dashboard_id dash-id- :creator_id (mt/user->id :trashbird)- :parameters [(assoc param :value ["LinkedIn"])]- :disable_links disable-links?}- :model/PulseCard _ {:pulse_id bad-slack-pulse-id- :card_id card-id- :dashboard_card_id dash-card-id}- :model/PulseChannel _ {:channel_type :slack- :pulse_id bad-slack-pulse-id- :details {:channel "#my-channel"}- :enabled true}- ;; Non broken pulse- :model/Pulse {good-pulse-id :id} {:name "Good Pulse"- :dashboard_id dash-id- :creator_id (mt/user->id :trashbird)}- :model/PulseCard _ {:pulse_id good-pulse-id- :card_id card-id- :dashboard_card_id dash-card-id}- :model/PulseChannel {good-pulse-channel-id :id} {:channel_type :email- :pulse_id good-pulse-id- :enabled true}- :model/PulseChannelRecipient _ {:pulse_channel_id good-pulse-channel-id- :user_id (mt/user->id :rasta)}- :model/PulseChannelRecipient _ {:pulse_channel_id good-pulse-channel-id- :user_id (mt/user->id :crowberto)}]- (testing "The pulses are active"- (is (false? (t2/select-one-fn :archived :model/Pulse bad-pulse-id)))- (is (false? (t2/select-one-fn :archived :model/Pulse good-pulse-id))))- (mt/with-fake-inbox- (let [{:keys [parameters]} (dashboard-response (mt/user-http-request- :rasta :put 200 (str "dashboard/" dash-id)- {:parameters []}))- title (format "Subscription to %s removed" dashboard-name)- ;; Keep only the relevant messages. If not, you might get some other side-effecting email, such- ;; as "We've Noticed a New Metabase Login, Rasta".- inbox (update-vals- @mt/inbox- (fn [messages]- (filterv (comp #{title} :subject) messages)))- emails-received? (fn [recipient-email]- (testing "The first email was received"- (is (true? (some-> (get-in inbox [recipient-email 0 :body 0 :content])- (str/includes? title)))))- (testing "The second email (about the broken slack pulse) was received"- (is (= match-email-body-pattern? (some-> (get-in inbox [recipient-email 1 :body 0 :content])- (str/includes? email-body-pattern))))))]- (testing "The dashboard parameters were removed"- (is (empty? parameters)))- (testing "The broken pulse was archived"- (is (true? (t2/select-one-fn :archived :model/Pulse bad-pulse-id))))- (testing "The unbroken pulse is still active"- (is (false? (t2/select-one-fn :archived :model/Pulse good-pulse-id))))- (testing "The dashboard and pulse creators were emailed about the removed pulse"- (is (= #{"[email protected]" "[email protected]"}- (set (keys inbox)))))- (testing "Notification emails were sent to the dashboard and pulse creators"- (emails-received? "[email protected]")- (emails-received? "[email protected]"))))))))(testing "When a subscriptions is broken, archive it and notify the dashboard and subscription creator (#30100)"(test-handle-broken-subscription-notification!{:disable-links? falsediff --git a/test/metabase/driver/h2_test.clj b/test/metabase/driver/h2_test.cljindex c836fb906e0..fcfac824482 100644--- a/test/metabase/driver/h2_test.clj+++ b/test/metabase/driver/h2_test.clj@@ -303,12 +303,12 @@(let [trigger-creation-attempt (str/join "\n" ["DROP TRIGGER IF EXISTS MY_SPECIAL_TRIG;""CREATE OR REPLACE TRIGGER MY_SPECIAL_TRIG BEFORE SELECT ON INFORMATION_SCHEMA.Users AS '';""SELECT * FROM INFORMATION_SCHEMA.Users;"])]- (is (thrown? clojure.lang.ExceptionInfo- #"DDL commands are not allowed to be used with h2."- (#'h2/check-action-commands-allowed- {:database (mt/id)- :engine :h2- :native {:query trigger-creation-attempt}}))))))+ (is (thrown-with-msg? clojure.lang.ExceptionInfo+ #"DDL commands are not allowed to be used with H2."+ (#'h2/check-action-commands-allowed+ {:database (mt/id)+ :engine :h2+ :native {:query trigger-creation-attempt}}))))))(defn- check-read-only-statements [query](mt/with-metadata-provider (mt/id)diff --git a/test/metabase/driver/mysql_test.clj b/test/metabase/driver/mysql_test.cljindex 99335b5ad6e..87916bd350e 100644--- a/test/metabase/driver/mysql_test.clj+++ b/test/metabase/driver/mysql_test.clj@@ -1464,6 +1464,6 @@(deftest ^:parallel query-error-evidence-test(mt/test-driver :mysql- (doseq [[state code expected] [["HY000" 4176 true] ["HY000" 1205 false] [nil 4176 false]]]+ (doseq [[^String state code expected] [["HY000" 4176 true] ["HY000" 1205 false] [nil 4176 false]]](is (= expected (sql-jdbc.execute/impl-error-in-query?- :mysql (SQLTransientConnectionException. "Row read failed" state code)))))))+ :mysql (SQLTransientConnectionException. "Row read failed" state (int code))))))))diff --git a/test/metabase/driver/sql_jdbc/execute_test.clj b/test/metabase/driver/sql_jdbc/execute_test.cljindex 6b39d8ea36d..1125ca0ac7a 100644--- a/test/metabase/driver/sql_jdbc/execute_test.clj+++ b/test/metabase/driver/sql_jdbc/execute_test.clj@@ -421,5 +421,5 @@(deftest ^:parallel default-query-error-evidence-test(let [classify (get-method sql-jdbc.execute/impl-error-in-query? :sql-jdbc)]- (doseq [state ["21000" "22012" "23505" "42S22"]]+ (doseq [^String state ["21000" "22012" "23505" "42S22"]](is (true? (classify nil (SQLException. "Query error" state)))))))diff --git a/test/metabase/driver/sqlite_test.clj b/test/metabase/driver/sqlite_test.cljindex f082010342a..703e2aa46ae 100644--- a/test/metabase/driver/sqlite_test.clj+++ b/test/metabase/driver/sqlite_test.clj@@ -782,4 +782,4 @@(deftest ^:parallel query-error-evidence-test(mt/test-driver :sqlite(doseq [code [1 19 20]]- (is (true? (sql-jdbc.execute/impl-error-in-query? :sqlite (SQLException. "Query error" nil code)))))))+ (is (true? (sql-jdbc.execute/impl-error-in-query? :sqlite (SQLException. "Query error" nil (int code))))))))diff --git a/test/metabase/eid_translation/core_test.clj b/test/metabase/eid_translation/core_test.cljdeleted file mode 100644index e69de29bb2d..00000000000diff --git a/test/metabase/embedding_rest/api/embed_test.clj b/test/metabase/embedding_rest/api/embed_test.cljindex d8f6d250946..effcbf3003b 100644--- a/test/metabase/embedding_rest/api/embed_test.clj+++ b/test/metabase/embedding_rest/api/embed_test.clj@@ -2394,9 +2394,9 @@:latField (tiles.api-test/encoded-implicit-join-field-ref :latitude):lonField (tiles.api-test/encoded-implicit-join-field-ref :longitude)))))))))+;; Regression test for metabase#29371 - Case-sensitive field filters in embedded dashboards.+;; Embedded dashboards should apply case-insensitive default options for string operators.(deftest embedded-string-parameter-case-sensitivity-regression-test- "Regression test for metabase#29371 - Case-sensitive field filters in embedded dashboards.- Embedded dashboards should apply case-insensitive default options for string operators."(mt/dataset test-data(mt/with-temp[:model/Card card {:database_id (mt/id)diff --git a/test/metabase/lib/test_util/places_cam_likes_metadata_provider.cljc b/test/metabase/lib/test_util/places_cam_likes_metadata_provider.cljcindex 11f2fcbf2a6..37eaa49d366 100644--- a/test/metabase/lib/test_util/places_cam_likes_metadata_provider.cljc+++ b/test/metabase/lib/test_util/places_cam_likes_metadata_provider.cljc@@ -3,8 +3,6 @@[metabase.lib.test-metadata :as meta][metabase.lib.test-util :as lib.tu]))-(ns metabase.lib.test-util.places-cam-likes-metadata-provider)-(defn id([]1)diff --git a/test/metabase/linters/common.clj b/test/metabase/linters/common.cljnew file mode 100644index 00000000000..82e9994942c--- /dev/null+++ b/test/metabase/linters/common.clj@@ -0,0 +1,14 @@+(ns metabase.linters.common+ (:require+ [clojure.java.classpath :as classpath]+ [clojure.string :as str]))++(set! *warn-on-reflection* true)++(defn source-paths+ "Find all the Metabase Clojure source and test paths to lint."+ []+ (filter (fn [^java.io.File file]+ (and (.isDirectory ^java.io.File file)+ (not (str/ends-with? (.getName file) "resources"))))+ (classpath/system-classpath)))diff --git a/test/metabase/linters/eastwood.clj b/test/metabase/linters/eastwood.cljnew file mode 100644index 00000000000..4ab65dcba69--- /dev/null+++ b/test/metabase/linters/eastwood.clj@@ -0,0 +1,87 @@+(ns metabase.linters.eastwood+ (:require+ [eastwood.lint :as eastwood]+ [metabase.linters.common :as common])+ (:import (java.io File)))++(set! *warn-on-reflection* true)++(def ^:private ignored-faults+ "Linters to skip in a whole namespace, for findings that are deliberate.+ Eastwood can also match a line, but those entries break whenever an unrelated edit moves the code."+ '{:deprecations+ {;; every `Liquibase.update` overload that writes SQL to a `Writer` is deprecated; the replacement is the+ ;; command API+ metabase.app-db.liquibase true+ ;; `(URL. s)`: `URI` parses differently, and these check URLs that will then be fetched with `URL`'s own parsing+ metabase.driver.mysql true+ metabase.driver.sqlite true+ metabase.llm.provider.settings true+ metabase.llm.settings true+ metabase.server.middleware.ssl true+ metabase.util.http true+ ;; specmonstah has no replacement for `spec-gen-assoc-relations`+ metabase.test.generate true}++ :unused-ret-vals-in-try+ {;; `reduce-kv` run for its side effects, chosen for speed+ metabase.util.log true}++ :unused-ret-vals+ {;; a spy that calls the real function for its side effect+ metabase-enterprise.search.semantic.migration-test true+ ;; `Class/forName` to load the JDBC driver class+ metabase.driver.presto-jdbc-test true}++ ;; `(is true)` in branches that skip a test, or that follow a call whose only check is that it didn't throw+ :suspicious-test+ {metabase-enterprise.search.entity-retrieval.appdb-mode-test true+ metabase-enterprise.search.semantic.appdb-pgvector-mode-test true+ ;; `ts/with-db` wraps its body in `testing`, and Eastwood can't see that its value is used+ metabase-enterprise.serialization.v2.metric-dimensions-test true+ metabase.driver.clickhouse-impersonation-test true+ metabase.driver.mongo-test true}++ :constant-test+ {metabase-enterprise.search.entity-retrieval.appdb-mode-test true+ metabase-enterprise.search.semantic.appdb-pgvector-mode-test true+ metabase.driver.clickhouse-impersonation-test true+ metabase.driver.mongo-test true+ ;; macro tests over literal arguments+ metabase.util-test true+ metabase.util.match-test true}++ :def-in-def+ {;; these tests check `defsetting` itself+ metabase.settings.models.setting-test true}+ ;; this test checks `defsetting` in another namespace+ :wrong-ns-form {metabase.settings.models.setting-test true}})++(def ^:private default-options+ {:config-files ["test_resources/eastwood_config.clj"]+ :ignored-faults ignored-faults})++(defn eastwood+ "Entrypoint for running Eastwood from the CLI. Adds some programatically-determined config options. See comments in+ `deps.edn` for usage instructions."+ [options]+ (eastwood/eastwood-from-cmdline+ (merge+ default-options+ {:source-paths (common/source-paths)}+ options)))++(defn eastwood-tests+ "Entry-point for the :eastwood/test alias. Derives :source-paths from classpath directories+ whose basename is `test` so we don't have to hardcode the per-driver test paths in deps.edn —+ they're already on the classpath via :drivers-dev's :extra-paths. Excludes `.clj-kondo/test`,+ which is for clj-kondo hook tests and uses a different toolchain."+ [options]+ (eastwood/eastwood-from-cmdline+ (merge+ default-options+ {:source-paths (filterv (fn [^File f]+ (and (= "test" (.getName f))+ (not= ".clj-kondo" (some-> (.getParentFile f) .getName))))+ (common/source-paths))}+ options)))diff --git a/test/metabase/measures/models/measure_test.clj b/test/metabase/measures/models/measure_test.cljindex a51f74aac79..4945c8f326f 100644--- a/test/metabase/measures/models/measure_test.clj+++ b/test/metabase/measures/models/measure_test.clj@@ -71,9 +71,16 @@(is (thrown-with-msg?Exception#"[Cc]ycle"- (t2/update! :model/Measure measure-1-id {:definition (measure-definition-referencing measure-2-id)})))))+ (t2/update! :model/Measure measure-1-id {:definition (measure-definition-referencing measure-2-id)}))))))+;;; ------------------------------------------------ Metric Reference Tests ------------------------------------------------+;; TODO (Chris 2026-10-26) -- these tests fail.+;; They used to sit inside `update-measure-cycle-detection-test`, so they never ran.+;; Since #79521, `::lib.schema.measure/definition` reports every specific stage error, such as+;; "Measures cannot reference metrics" or "cannot use :joins", as the generic "stages must be measure stages".+;; Fix the schema so the specific message comes through, then move the tests out of this `comment`.+(comment(defn- metric-query"Create a metric-style dataset query (a query with a single aggregation)."[]diff --git a/test/metabase/metabot/agent/core_test.clj b/test/metabase/metabot/agent/core_test.cljindex eed09ba9d3f..5457ace5d35 100644--- a/test/metabase/metabot/agent/core_test.clj+++ b/test/metabase/metabot/agent/core_test.clj@@ -475,11 +475,10 @@(reset! captured llm-opts)(mut/mock-llm-response[{:type :text :text "Hello"}]))]- (into [] (run-agent-loop- {:messages [{:role :user :content "Hi"}]- :state {}- :profile-id :sql- :context {}}))+ (run-agent-loop! {:messages [{:role :user :content "Hi"}]+ :state {}+ :profile-id :sql+ :context {}})(is (= {:tool-choice "required"} @captured)))))(testing "runs agent loop with tool execution"(let [call-count (atom 0)]@@ -1002,12 +1001,11 @@:function "load_skill":arguments {:ids ["read-resource"]}}]))(mut/mock-llm-response [{:type :text :text "Done."}])))]- (into [] (run-agent-loop- {:messages [{:role :user :content "Help me with this dashboard."}]- :state {}- :profile-id :internal- :context {:current_user_time "2026-10-05T12:00:00Z"- :user_is_viewing [{:type "dashboard" :id dashboard-id}]}}))+ (run-agent-loop! {:messages [{:role :user :content "Help me with this dashboard."}]+ :state {}+ :profile-id :internal+ :context {:current_user_time "2026-10-05T12:00:00Z"+ :user_is_viewing [{:type "dashboard" :id dashboard-id}]}})(let [[{system-1 :system tools-1 :tools messages-1 :messages}{system-2 :system tools-2 :tools messages-2 :messages}] @requests](is (str/includes? (pr-str system-1) "Use British spelling."))diff --git a/test/metabase/metabot/self_test.clj b/test/metabase/metabot/self_test.cljindex 87a36188d12..95b8c28feb8 100644--- a/test/metabase/metabot/self_test.clj+++ b/test/metabase/metabot/self_test.clj@@ -1812,11 +1812,10 @@(let [_acc (rf init {:type :start :messageId "m1"})](throw (ex-info "mid-stream boom" {:status 500}))))))](mt/with-log-level [metabase.metabot.self :fatal]- (let [seen (atom [])- collect-rf (fn ([acc] acc) ([acc x] (swap! seen conj x) acc))]+ (let [seen (atom [])](is (thrown-with-msg?clojure.lang.ExceptionInfo #"mid-stream boom"- (reduce collect-rf nil (self/call-llm "openrouter/test-model" nil [] {} {:tag "metabot_agent"}))))+ (run! #(swap! seen conj %) (self/call-llm "openrouter/test-model" nil [] {} {:tag "metabot_agent"}))))(is (= 1 (count (filter #(= :start (:type %)) @seen)))"the :start part reaches the consumer exactly once, not once per retry attempt")))))))@@ -1834,8 +1833,7 @@(reduce rf init (test-util/mock-llm-response [{:type :start :id "m1"}]))))))](mt/with-log-level [metabase.metabot.self :fatal](let [seen (atom [])]- (reduce (fn [acc x] (swap! seen conj x) acc) nil- (self/call-llm "openrouter/test-model" nil [] {} {:tag "metabot_agent"}))+ (run! #(swap! seen conj %) (self/call-llm "openrouter/test-model" nil [] {} {:tag "metabot_agent"}))(is (= 3 @calls) "retries until the pre-emission failures clear")(is (= 1 (count (filter #(= :start (:type %)) @seen)))))))))))diff --git a/test/metabase/metabot/tools/entity_retrieval_test.clj b/test/metabase/metabot/tools/entity_retrieval_test.cljindex 921e02f7e2e..fabd928877c 100644--- a/test/metabase/metabot/tools/entity_retrieval_test.clj+++ b/test/metabase/metabot/tools/entity_retrieval_test.clj@@ -119,22 +119,22 @@(java.util.Locale/setDefault orig))))))(deftest dedupe-by-entity-test- (let [dedupe (var-get #'entity-retrieval/dedupe-by-entity)- results [{:entity {:model "metric" :id 9} :score {:total_score 0.95}} ; entity 9, best- {:entity {:model "metric" :id 9} :score {:total_score 0.80}} ; entity 9 again (sibling doc)- {:entity {:model "table" :id 1} :score {:total_score 0.70}}]]+ (let [dedupe-by-entity (var-get #'entity-retrieval/dedupe-by-entity)+ results [{:entity {:model "metric" :id 9} :score {:total_score 0.95}} ; entity 9, best+ {:entity {:model "metric" :id 9} :score {:total_score 0.80}} ; entity 9 again (sibling doc)+ {:entity {:model "table" :id 1} :score {:total_score 0.70}}]](testing "collapses to distinct entities, keeping the first (best-scoring) occurrence"- (let [out (dedupe results)]+ (let [out (dedupe-by-entity results)](is (= 2 (count out)))(is (= [0.95 0.70] (mapv (comp :total_score :score) out)))))(testing "\"card\" and \"question\" are aliases for the same Card, so they collapse to one entity"- (let [out (dedupe [{:entity {:model "card" :id 5} :score {:total_score 0.9}}- {:entity {:model "question" :id 5} :score {:total_score 0.8}}])]+ (let [out (dedupe-by-entity [{:entity {:model "card" :id 5} :score {:total_score 0.9}}+ {:entity {:model "question" :id 5} :score {:total_score 0.8}}])](is (= 1 (count out)))(is (= 0.9 (-> out first :score :total_score)))))(testing "measures and segments are first-class distinct entities"- (let [out (dedupe [{:entity {:model "measure" :id 3} :score {:total_score 0.9}}- {:entity {:model "segment" :id 3} :score {:total_score 0.8}}])]+ (let [out (dedupe-by-entity [{:entity {:model "measure" :id 3} :score {:total_score 0.9}}+ {:entity {:model "segment" :id 3} :score {:total_score 0.8}}])](is (= 2 (count out)))))))(deftest format-output-testdiff --git a/test/metabase/metabot/tools/run_query_test.clj b/test/metabase/metabot/tools/run_query_test.cljindex cc72a3d13a8..71be9840f4f 100644--- a/test/metabase/metabot/tools/run_query_test.clj+++ b/test/metabase/metabot/tools/run_query_test.clj@@ -607,10 +607,10 @@"a SQL question" sql-card"a notebook question over a SQL question" over-sql-card"a SQL question Metabot saved, edited since" edited-sql-card}- run! [run-sql-off-tool! run-sql-tool!]]+ tool! [run-sql-off-tool! run-sql-tool!]](testing shape(is (=? {:structured-output {:returned 1, :truncated? false}}- (run! {"q1" (card-query card-id)} {:query_id "q1"}))))))+ (tool! {"q1" (card-query card-id)} {:query_id "q1"}))))))(testing "a user without native query permission can read a saved SQL question"(mt/with-no-data-perms-for-all-users!(perms/set-database-permission! (perms-group/all-users) (mt/id) :perms/view-data :unrestricted)@@ -645,9 +645,9 @@(run-sql-tool! {"q1" (card-query metabot-write-card)} {:query_id "q1"}))))(is (false? @ran?)))))(testing "SQL Metabot saved under a question the user can't read gets the permission refusal"- (doseq [run! [run-sql-off-tool! run-sql-tool!]]+ (doseq [tool! [run-sql-off-tool! run-sql-tool!]](is (= no-permission- (run! {"q1" (card-query over-hidden-sql)} {:query_id "q1"})))))+ (tool! {"q1" (card-query over-hidden-sql)} {:query_id "q1"})))))(testing "SQL that references a question the user can't read is refused before it is compiled"(let [tag (str "#" hidden-metabot-sql)](is (= no-permissiondiff --git a/test/metabase/notification/events/notification_test.clj b/test/metabase/notification/events/notification_test.cljindex edfeae0abca..a2b563a5a61 100644--- a/test/metabase/notification/events/notification_test.clj+++ b/test/metabase/notification/events/notification_test.clj@@ -90,24 +90,25 @@{:user_id (mt/user->id :rasta):topic :user-joined}{:user_id (mt/user->id :rasta)- :user (t2/select-one user-hydra-model (mt/user->id :rasta))}]+ :user (t2/select-one user-hydra-model (mt/user->id :rasta))+ :topic :user-joined}]["multiple hydration in the same map"[:map(-> [:user_id :int] (#'events.schema/with-hydrate :user user-hydra-model))- (-> [:creator :int] (#'events.schema/with-hydrate :creator user-hydra-model))]+ (-> [:creator_id :int] (#'events.schema/with-hydrate :creator user-hydra-model))]{:user_id (mt/user->id :rasta):creator_id (mt/user->id :crowberto)}{:user_id (mt/user->id :rasta):user (t2/select-one user-hydra-model (mt/user->id :rasta)):creator_id (mt/user->id :crowberto)- :creator (t2/select-one user-hydra-model (mt/user->id :rasta))}]+ :creator (t2/select-one user-hydra-model (mt/user->id :crowberto))}]["respect the options"[:map(-> [:user_id {:optional true} :int] (#'events.schema/with-hydrate :user user-hydra-model))]{}{}]]](testing context- (= expected (#'events.notification/hydrate! schema value)))))+ (is (= expected (#'events.notification/hydrate! schema value))))))(deftest record-task-history-test(notification.tu/with-notification-testing-setup!diff --git a/test/metabase/notification/payload/impl/card_test.clj b/test/metabase/notification/payload/impl/card_test.cljindex b99bc817a94..46a04fbdb0b 100644--- a/test/metabase/notification/payload/impl/card_test.clj+++ b/test/metabase/notification/payload/impl/card_test.clj@@ -562,7 +562,7 @@(t2/delete! :model/TaskHistory)(is (thrown-with-msg?clojure.lang.ExceptionInfo- #"Failed to execute card with error: Division by zero: " 1 ""+ #"Failed to execute card with error: Division by zero: "(#'notification.send/send-notification-sync! notification)))(is (=? [{:status :failed:task_details {:message (mt/malli=? [:fn #(str/includes? % "Division by zero")])}}]diff --git a/test/metabase/parameters/dashboard_test.clj b/test/metabase/parameters/dashboard_test.cljindex 987c01d44aa..51eb812e419 100644--- a/test/metabase/parameters/dashboard_test.clj+++ b/test/metabase/parameters/dashboard_test.clj@@ -87,9 +87,9 @@:type "date/all-options"}]})](is (= "completed" (:status response))))))))))+;; Test for issue #47951: Dashboard filters should show remapped values even when+;; user has view-data but not create-queries permissions on the target table.(deftest ^:synchronized dashboard-remapping-multi-field-permissions-test- "Test for issue #47951: Dashboard filters should show remapped values even when- user has view-data but not create-queries permissions on the target table."(testing "Dashboard parameter remapping with multi-field FK scenario"(mt/dataset test-data(let [orders-product-id-field-id (mt/id :orders :product_id)diff --git a/test/metabase/public_sharing_rest/api_test.clj b/test/metabase/public_sharing_rest/api_test.cljindex c69b7c90de1..9fa3a460b95 100644--- a/test/metabase/public_sharing_rest/api_test.clj+++ b/test/metabase/public_sharing_rest/api_test.clj@@ -1076,12 +1076,12 @@(is (partial= [:name] ; id is hidden(-> public-action :visualization_settings :fields keys))))(testing "the action should only include the columns shown for public actions"- (= #{:name- :id- :database_id- :visualization_settings- :parameters}- (set (keys public-action))))))))))))+ (is (= #{:name+ :id+ :database_id+ :visualization_settings+ :parameters}+ (set (keys public-action)))))))))))));;; --------------------------------- GET /api/public/dashboard/:uuid/card/:card-id ----------------------------------diff --git a/test/metabase/query_processor/aggregation_test.clj b/test/metabase/query_processor/aggregation_test.cljindex 06fb5531170..7e0c792f0b3 100644--- a/test/metabase/query_processor/aggregation_test.clj+++ b/test/metabase/query_processor/aggregation_test.clj@@ -256,7 +256,7 @@(deftest ^:synchronized complex-distinct-aggregation-test(mt/test-drivers (mt/normal-drivers-with-feature ::complex-distinct-aggregation-test)(testing "Aggregation as `Count / Distinct([SOME_FIELD])` returns expected results (#35425)"- (every?+ (run!(fn [[_id c d c-div-d more-complex]](testing "Simple division"(is (= (u/round-to-decimals 2 (double (/ c d)))diff --git a/test/metabase/query_processor/middleware/cache_test.clj b/test/metabase/query_processor/middleware/cache_test.cljindex 58056358225..243963497e6 100644--- a/test/metabase/query_processor/middleware/cache_test.clj+++ b/test/metabase/query_processor/middleware/cache_test.clj@@ -680,9 +680,9 @@;; the QP pipeline on worker threads that don't inherit *local-redefs* — use with-redefs.;; [kondo-keep] suppresses a warning :redundant-ignore can't see; --audit rechecks#_{:clj-kondo/ignore [:metabase/prefer-with-dynamic-fn-redefs]}- (with-redefs [process-userland-query/save-execution-metadata!* (fn [& args]+ (with-redefs [process-userland-query/save-execution-metadata!* (fn [query-executions](swap! save-execution-metadata-count inc)- (apply save-execution-metadata-original args)+ (save-execution-metadata-original query-executions)(deliver called-promise true))query/save-queries-and-update-average-execution-times! (fn [entries](swap! update-avg-execution-count + (count entries))diff --git a/test/metabase/revisions/models/revision_test.clj b/test/metabase/revisions/models/revision_test.cljindex 21436dc35f1..972fd5f1e43 100644--- a/test/metabase/revisions/models/revision_test.clj+++ b/test/metabase/revisions/models/revision_test.clj@@ -506,17 +506,17 @@:is_reversion true:is_creation false}))))(testing "multiple changes"- {:description "changed the display from table to bar and turned this into a model."- :has_multiple_changes true}- (#'revision/revision-description-info model- {:object {:type "question"- :display :table}- :is_reversion false- :is_creation false}- {:object {:type "model"- :display :bar}- :is_reversion false- :is_creation false}))+ (is (= {:description "changed the display from table to bar and turned this to a model."+ :has_multiple_changes true}+ (#'revision/revision-description-info model+ {:object {:type "question"+ :display :table}+ :is_reversion false+ :is_creation false}+ {:object {:type "model"+ :display :bar}+ :is_reversion false+ :is_creation false}))))(testing "changes contains unspecified keys will not be mentioned"(is (= {:description "turned this to a model.":has_multiple_changes false}diff --git a/test/metabase/search/embeddings/embedder_plugin_artifact_test.clj b/test/metabase/search/embeddings/embedder_plugin_artifact_test.cljindex 221e25bcd1a..560fb03f90e 100644--- a/test/metabase/search/embeddings/embedder_plugin_artifact_test.clj+++ b/test/metabase/search/embeddings/embedder_plugin_artifact_test.clj@@ -139,9 +139,8 @@"a catalog entry missing this architecture's export fails instead of hashing nil"))))(deftest ^:synchronized plugin-artifact-smoke-test- (if-not (= "true" (System/getenv "MB_EMBEDDER_ARTIFACT_TEST"))- (testing "artifact smoke is enabled only in its dedicated CI process"- (is true))+ ;; The artifact smoke runs only in its dedicated CI process.+ (when (= "true" (System/getenv "MB_EMBEDDER_ARTIFACT_TEST"))(let [pre-plugin-thread(isolated-thread-call#(hash-map :readiness (embeddings.provider/readiness retrieval-model)diff --git a/test/metabase/search/index_health_test.clj b/test/metabase/search/index_health_test.cljindex f1a71cba87a..128132e4ba4 100644--- a/test/metabase/search/index_health_test.clj+++ b/test/metabase/search/index_health_test.clj@@ -112,19 +112,19 @@(deftest ^:synchronized failed-first-write-does-not-mark-series-live-test(testing "a failed first gauge write does not make later clears create a NaN-only series"- (let [set-index-gauge! @#'index-health/set-index-gauge!- live @#'index-health/live-gauge-series- series [:metabase-search/index-coverage-ratio :failed-write-test-engine]- calls (atom [])]+ (let [set-index-gauge! @#'index-health/set-index-gauge!+ live @#'index-health/live-gauge-series+ [gauge-key index :as series] [:metabase-search/index-coverage-ratio :failed-write-test-engine]+ calls (atom [])](try(mt/with-dynamic-fn-redefs [analytics/set-gauge! (fn [& _](throw (ex-info "prometheus down" {})))]- (is (thrown? Exception (apply set-index-gauge! (conj series 1.0))))+ (is (thrown? Exception (set-index-gauge! gauge-key index 1.0)))(is (not (contains? @live series))))(mt/with-dynamic-fn-redefs [analytics/set-gauge! (fn [& args] (swap! calls conj (vec args)))]- (apply set-index-gauge! (conj series nil))+ (set-index-gauge! gauge-key index nil)(is (empty? @calls))- (apply set-index-gauge! (conj series 0.5))+ (set-index-gauge! gauge-key index 0.5)(is (contains? @live series)))(finally(swap! live disj series))))))diff --git a/test/metabase/server/streaming_response_test.clj b/test/metabase/server/streaming_response_test.cljindex 044df23bb3a..91a2426071d 100644--- a/test/metabase/server/streaming_response_test.clj+++ b/test/metabase/server/streaming_response_test.clj@@ -25,7 +25,7 @@(java.io ByteArrayOutputStream Closeable InputStream)(java.util.concurrent CountDownLatch Executors Future TimeUnit)(java.util.concurrent.atomic AtomicBoolean)- (org.apache.commons.lang3.concurrent BasicThreadFactory$Builder)))+ (org.apache.commons.lang3.concurrent BasicThreadFactory)))(set! *warn-on-reflection* true)@@ -38,7 +38,7 @@(defn- do-with-streaming-response-thread-pool! [thunk](let [pool (Executors/newFixedThreadPool thread-pool-size(.build- (doto (BasicThreadFactory$Builder.)+ (doto (BasicThreadFactory/builder)(.namingPattern "streaming-response-test-thread-pool-%d");; Daemon threads do not block shutdown of the JVM(.daemon true))))]diff --git a/test/metabase/session/api_test.clj b/test/metabase/session/api_test.cljindex fe6041345fd..0001b96f058 100644--- a/test/metabase/session/api_test.clj+++ b/test/metabase/session/api_test.clj@@ -670,6 +670,13 @@(mt/with-temp-env-var-value! [mb-reset-token-ttl-hours -1](is (= -1 (setting/get-value-of-type :integer :reset-token-ttl-hours)))))))+(defsetting test-session-api-setting+ "test setting"+ :encryption :no+ :user-local :only+ :type :string+ :default "FOO")+(deftest properties-test(testing "GET /session/properties"(testing "Unauthenticated"@@ -689,12 +696,6 @@(is (= (set (keys (setting/user-readable-values-map #{:public :authenticated :settings-manager :admin-write-authed-read :admin})))(set (keys (mt/user-http-request :crowberto :get 200 "session/properties")))))))(testing "Includes user-local settings"- (defsetting test-session-api-setting- "test setting"- :encryption :no- :user-local :only- :type :string- :default "FOO")(mt/with-test-user :lucky(is (= "FOO"(-> (mt/user-http-request :crowberto :get 200 "session/properties")diff --git a/test/metabase/session/task/session_cleanup_test.clj b/test/metabase/session/task/session_cleanup_test.cljindex cec99dd3bc6..b05fe8ef25d 100644--- a/test/metabase/session/task/session_cleanup_test.clj+++ b/test/metabase/session/task/session_cleanup_test.clj@@ -9,8 +9,7 @@[metabase.util :as u][toucan2.core :as t2])(:import- (metabase.session.task.session_cleanup SessionCleanup)- (org.quartz Job)))+ (metabase.session.task.session_cleanup SessionCleanup)))(set! *warn-on-reflection* true)@@ -118,7 +117,7 @@(session/record-session-activity-update! key-hash);; the cache only drops entries older than the throttle window, so make every entry look stale(mt/with-dynamic-fn-redefs [u/since-ms (constantly Long/MAX_VALUE)]- (.execute ^Job (SessionCleanup.) nil))+ (.execute (SessionCleanup.) nil))(is (true? (session/record-session-activity-update! key-hash))"a pruned session is no longer throttled"))))diff --git a/test/metabase/settings/models/setting_test.clj b/test/metabase/settings/models/setting_test.cljindex e18e2cd8803..165a39bd6e6 100644--- a/test/metabase/settings/models/setting_test.clj+++ b/test/metabase/settings/models/setting_test.clj@@ -675,28 +675,28 @@(is (= "toucan-name" (:setting-key (ex-data e))))))))(deftest setting-value-aad-test- (let [read #'setting/read-setting-value]+ (let [read-value #'setting/read-setting-value](encryption-test/with-secret-key "ABCDEFGH12345678"(testing "a value round trips through the AAD naming its setting"(is (= "Sad Can"- (:value (read {:key "test-setting-1"- :value_with_aad (encryption/encrypt "Sad Can" (aad-opts :test-setting-1))})))))+ (:value (read-value {:key "test-setting-1"+ :value_with_aad (encryption/encrypt "Sad Can" (aad-opts :test-setting-1))})))))(testing "a value moved to another setting's row is rejected, and the message never carries the value"(let [e (is (thrown-with-msg? clojure.lang.ExceptionInfo#"Error reading setting \"test-setting-2\""- (read {:key "test-setting-2"- :value_with_aad (encryption/encrypt "Sad Can" (aad-opts :test-setting-1))})))]+ (read-value {:key "test-setting-2"+ :value_with_aad (encryption/encrypt "Sad Can" (aad-opts :test-setting-1))})))](is (not (re-find #"Sad Can" (ex-message e))))))(testing "a plaintext value is rejected while a key is set"(is (thrown-with-msg? clojure.lang.ExceptionInfo#"Expected an encrypted value"- (read {:key "test-setting-1" :value_with_aad "Sad Can"}))))+ (read-value {:key "test-setting-1" :value_with_aad "Sad Can"}))))(testing "a row written only by a version predating `value_with_aad` reads as no value at all"(is (= {:key "test-setting-1" :value nil :value_with_aad nil}- (read {:key "test-setting-1" :value "Sad Can" :value_with_aad nil}))))+ (read-value {:key "test-setting-1" :value "Sad Can" :value_with_aad nil}))))(testing "a key with no `defsetting` reads as no value at all, without so much as a decrypt"(is (= {:key "no-such-setting" :value nil :value_with_aad "not even ciphertext"}- (read {:key "no-such-setting" :value_with_aad "not even ciphertext"})))))+ (read-value {:key "no-such-setting" :value_with_aad "not even ciphertext"})))))(testing "a key with no `defsetting` cannot be written: how it is stored is the setting's to decide"(is (thrown-with-msg? clojure.lang.ExceptionInfo #"Unknown setting: no-such-setting"(#'setting/write-setting-value {:key "no-such-setting" :value "Sad Can"}))))))@@ -1813,14 +1813,14 @@(deftest validation-completeness-test(let [formats-to-check (disj (set (keys (methods setting/get-value-of-type))) :string)](testing "Every settings format has its redaction predicate defined"- (doseq [format formats-to-check]- (testing (format "We have defined a redaction multimethod for the %s format" format)- (is (some? (format (methods setting/may-contain-raw-token?)))))))+ (doseq [fmt formats-to-check]+ (testing (format "We have defined a redaction multimethod for the %s format" fmt)+ (is (some? (fmt (methods setting/may-contain-raw-token?)))))))(testing "Every settings format has tests for its validation"- (doseq [format formats-to-check]+ (doseq [fmt formats-to-check];; We operate on trust that tests are added along with this var- (testing (format "We have defined a setting for the %s validation tests" format)- (is (var? (resolve (ns-validation-setting-symbol format)))))))))+ (testing (format "We have defined a setting for the %s validation tests" fmt)+ (is (var? (resolve (ns-validation-setting-symbol fmt)))))))))(deftest migrate-settings!-test(testing "rows a version predating `value_with_aad` wrote get it filled in from `value` on startup"diff --git a/test/metabase/setup_rest/api_test.clj b/test/metabase/setup_rest/api_test.cljindex 25f8a25b33f..1cf5afba0fd 100644--- a/test/metabase/setup_rest/api_test.clj+++ b/test/metabase/setup_rest/api_test.clj@@ -284,8 +284,8 @@(with-redefs [api.setup/*allow-api-setup-after-first-user-is-created* truedriver.settings/*allow-testing-h2-connections* trueapi.setup/setup-set-settings! (let [orig @#'api.setup/setup-set-settings!]- (fn [& args]- (apply orig args)+ (fn [settings]+ (orig settings)(throw (ex-info "Oops!" {}))))](is (=? {:message "Oops!"}(client/client :post 500 "setup" body))))diff --git a/test/metabase/sso/ldap_tls_test.clj b/test/metabase/sso/ldap_tls_test.cljindex 3f8a4424d30..61bc1875661 100644--- a/test/metabase/sso/ldap_tls_test.clj+++ b/test/metabase/sso/ldap_tls_test.clj@@ -50,12 +50,12 @@way the JVM `cacerts` file is stored. Returns the trust store path."^String [^ObjectPair pair](let [pw ^chars (.getSecond pair)- src ^KeyStore (doto ^KeyStore (KeyStore/getInstance (KeyStore/getDefaultType))- (.load (io/input-stream (.getFirst pair)) pw))+ src (doto ^KeyStore (KeyStore/getInstance (KeyStore/getDefaultType))+ (.load (io/input-stream (.getFirst pair)) pw))cert (.getCertificate src (first (enumeration-seq (.aliases src))))- trust ^KeyStore (doto ^KeyStore (KeyStore/getInstance "pkcs12")- (.load nil nil)- (.setCertificateEntry "ldap-ca" cert))+ trust (doto ^KeyStore (KeyStore/getInstance "pkcs12")+ (.load nil nil)+ (.setCertificateEntry "ldap-ca" cert))out ^File (File/createTempFile "ldap-trust" ".ks")cert-alg (Security/getProperty "keystore.pkcs12.certProtectionAlgorithm")mac-alg (Security/getProperty "keystore.pkcs12.macAlgorithm")]@@ -86,7 +86,7 @@ldap-port portldap-security :ssl](is (thrown? Exception- (with-open [^java.lang.AutoCloseable _conn (#'ldap/get-connection)]))+ (with-open [^java.lang.AutoCloseable _conn (#'ldap/get-connection)] nil))"a certificate outside the trust store must not complete the TLS handshake")))(testing "a certificate present in the configured trust store connects (positive control)"(mt/with-temporary-setting-values [ldap-host "localhost"diff --git a/test/metabase/task/secure_delegate/core_test.clj b/test/metabase/task/secure_delegate/core_test.cljindex bbf4d6f3729..8ddc79bbca5 100644--- a/test/metabase/task/secure_delegate/core_test.clj+++ b/test/metabase/task/secure_delegate/core_test.clj@@ -47,7 +47,7 @@;; reflectively, unwrapping the InvocationTargetException so the filter's own exception surfaces.(defn- read-through-delegate! [db-type result-set-fn obj](let [k (Class/forName (secure-delegate/install! db-type) true (classloader/the-classloader))- delegate (.newInstance k)+ delegate (.newInstance (.getDeclaredConstructor k (into-array Class [])) (object-array 0))m (.getMethod k "getObjectFromBlob" (into-array Class [ResultSet String]))](try(.invoke m delegate (object-array [(result-set-fn (serialize-bytes obj)) "data"]))diff --git a/test/metabase/test/data/gc.clj b/test/metabase/test/data/gc.cljindex 17555f638e3..25001d54eb1 100644--- a/test/metabase/test/data/gc.clj+++ b/test/metabase/test/data/gc.clj@@ -67,7 +67,6 @@(let [results (try(vec (tx/gc-orphans! driver options))(catch Exception e- (def ee e)[{:name nil, :status :failed, :error (ex-message e)}]))remaining (census! driver){:keys [deleted failed]} (group-by :status results)]diff --git a/test/metabase/test/util.clj b/test/metabase/test/util.cljindex 4c81e341195..e30e89a9060 100644--- a/test/metabase/test/util.clj+++ b/test/metabase/test/util.clj@@ -507,9 +507,10 @@(defn- set-with-temp-defaults! [](doseq [[model defaults-fn] with-temp-defaults-fns]- (methodical/defmethod t2.with-temp/with-temp-defaults model- [model]- (defaults-fn model))))+ (methodical/add-primary-method! #'t2.with-temp/with-temp-defaults+ model+ (fn [_next-method model]+ (defaults-fn model)))))(set-with-temp-defaults!)diff --git a/test/metabase/test/util/dynamic_redefs_test.clj b/test/metabase/test/util/dynamic_redefs_test.cljindex 4f4ff69b5b3..ea2390265cc 100644--- a/test/metabase/test/util/dynamic_redefs_test.clj+++ b/test/metabase/test/util/dynamic_redefs_test.clj@@ -22,8 +22,7 @@(deftest ^:parallel with-dynamic-fn-redefs-test(testing "Three threads can independently redefine a regular var"(let [n-threads 3- ;; Note that .getId is deprecated in favor of .threadId, but that method is only introduced in Java 19- thread-id #(.getId (Thread/currentThread))+ thread-id #(.threadId (Thread/currentThread))latch (CountDownLatch. (inc n-threads))take-latch #(do(.countDown latch)@@ -106,14 +105,15 @@(defn mock-me-outer [](mock-me-inner))+(defn- z []+ (mt/with-dynamic-fn-redefs [mock-me-outer+ (let [orig (mt/original-fn #'mock-me-outer)]+ (fn []+ (mt/with-dynamic-fn-redefs [mock-me-inner (constantly :mock/redefined)]+ (orig))))]+ (mock-me-outer)))+(deftest with-dynamic-fn-redefs-nested-binding-test- (defn z []- (mt/with-dynamic-fn-redefs [mock-me-outer- (let [orig (mt/original-fn #'mock-me-outer)]- (fn []- (mt/with-dynamic-fn-redefs [mock-me-inner (constantly :mock/redefined)]- (orig))))]- (mock-me-outer)))(is (= :mock/redefined (z))))(defn capture-bug-target [x] (inc x))diff --git a/test/metabase/tracing/quartz_test.clj b/test/metabase/tracing/quartz_test.cljindex 65e2e09f3d6..f7c54ce1134 100644--- a/test/metabase/tracing/quartz_test.clj+++ b/test/metabase/tracing/quartz_test.clj@@ -58,7 +58,8 @@(swap! stmt-calls-atom conj :rollback))(commit [_](swap! stmt-calls-atom conj :commit))- (close [_])+ (close [_]+ (swap! stmt-calls-atom conj :close-connection))(isClosed [_] false)))(defn- mock-job-execution-context@@ -114,8 +115,7 @@traced (#'tracing.quartz/traced-connection conn)](testing "close delegates to original"(.close ^Connection traced)- ;; no exception means the method was delegated- (is true))+ (is (= [:close-connection] @calls)))(testing "isClosed delegates to original"(is (false? (.isClosed ^Connection traced)))))(finallydiff --git a/test/metabase/upload/impl_test.clj b/test/metabase/upload/impl_test.cljindex 5818557d310..9e9e0068c7a 100644--- a/test/metabase/upload/impl_test.clj+++ b/test/metabase/upload/impl_test.clj@@ -410,12 +410,12 @@(defn do-with-upload-table! [table thunk](try (thunk table)(finally- ;; I'm experimenting with disabling this, it seems preposterous that this would actually cause test flakes --- ;; Cam- (when true #_(not= driver/*driver* :redshift) ; redshift tests flake when tables are dropped- (driver/drop-table! driver/*driver*- (:db_id table)- (#'upload/table-identifier table))))))+ ;; This used to be skipped on Redshift, whose tests were said to flake when tables are dropped. I'm+ ;; experimenting with disabling that skip, it seems preposterous that this would actually cause test flakes+ ;; -- Cam+ (driver/drop-table! driver/*driver*+ (:db_id table)+ (#'upload/table-identifier table)))))(defn- table->card [table](t2/select-one :model/Card :table_id (:id table)))@@ -607,7 +607,7 @@(sort-by :database_position)(map (juxt (comp u/lower-case-en :name) identity))))))(testing "Check that table can be written via data-editing"- (true? (t2/select-one-fn :is_writable [:model/Table :is_writable] (:id table))))+ (is (true? (t2/select-one-fn :is_writable [:model/Table :is_writable] (:id table)))))(testing "Check the data was uploaded into the table"(is (= 2(count (rows-for-table table)))))))))))diff --git a/test/metabase/util/format_test.clj b/test/metabase/util/format_test.cljindex 774f1f572b5..0a373121079 100644--- a/test/metabase/util/format_test.clj+++ b/test/metabase/util/format_test.clj@@ -10,4 +10,4 @@["candies" 2 "candy" "candies"]["books" 2 "book" nil]]](testing (format "format-plural %d %s %s" n singular plural)- (= expected (u/format-plural n singular plural)))))+ (is (= expected (u/format-plural n singular plural))))))diff --git a/test/metabase/util/formatting/date_test.cljc b/test/metabase/util/formatting/date_test.cljcindex 599296d160e..ee4dd7f829f 100644--- a/test/metabase/util/formatting/date_test.cljc+++ b/test/metabase/util/formatting/date_test.cljc@@ -13,7 +13,7 @@#?(:cljs (comment metabase.test-runner.assert-exprs.approximately-equal/keep-me))(def ^:private locale- #?(:cljs nil :clj (Locale. "en")))+ #?(:cljs nil :clj (Locale/of "en")))(def ^:private time-config {:start-of-week :sunday})diff --git a/test/metabase/util/http_test.clj b/test/metabase/util/http_test.cljindex 40b7e56d30d..5d6a0334c2d 100644--- a/test/metabase/util/http_test.clj+++ b/test/metabase/util/http_test.clj@@ -66,11 +66,11 @@(deftest ^:parallel host-allowed-host-shapes-test(testing "hosts are accepted in any of the shapes `->hostname` understands"(are [host expected] (= expected (http/host-allowed-for-network-policy? :external-only host))- "127.0.0.1" false- "127.0.0.1:5432" false- "[::1]:5432" false- "jdbc:postgresql://10.0.0.1/db" false- (java.net.URL. "http://10.0.0.1/x") false)))+ "127.0.0.1" false+ "127.0.0.1:5432" false+ "[::1]:5432" false+ "jdbc:postgresql://10.0.0.1/db" false+ (.toURL (java.net.URI. "http://10.0.0.1/x")) false)))(deftest ^:parallel host-allowed-alternate-encodings-test(testing "alternate encodings of a non-public address are refused, however they resolve"diff --git a/test/metabase/util/malli/defn_test.clj b/test/metabase/util/malli/defn_test.cljindex c536a66690d..920f1fd2527 100644--- a/test/metabase/util/malli/defn_test.clj+++ b/test/metabase/util/malli/defn_test.clj@@ -54,7 +54,7 @@(is (=? {:humanized {:x ["should be an int, got: \"3\""]:y ["missing required key, got: nil"]}}(try (baz)- (catch Exception e (def eed (ex-data e)) eed)))+ (catch Exception e (ex-data e))))"when baz returns an invalid form um/defn throws")(is (= "Inputs: []\n Return: [:map [:x int?] [:y int?]]"(:doc (meta #'baz))))))diff --git a/test/metabase/util/malli/fn_test.clj b/test/metabase/util/malli/fn_test.cljindex 060055dfa85..c88004b48cf 100644--- a/test/metabase/util/malli/fn_test.clj+++ b/test/metabase/util/malli/fn_test.clj@@ -318,9 +318,12 @@(deftest ^:parallel error-location-tests(tools.macro/macrolet [(check-error-location [expr]- `(try ~expr- (is false "Did not throw")- (catch Exception e# (from-here? e#))))]+ `(let [e# (try ~expr+ nil+ (catch Exception ex# ex#))]+ (is (some? e#) "Did not throw")+ (when e#+ (from-here? e#))))](testing "Top stack trace is this namespace, not in validate"(testing "single arity input"(check-error-location (foo 1)))diff --git a/test/metabase/util/memoize_test.cljc b/test/metabase/util/memoize_test.cljcindex cdd06ecd76e..8e076b7f4e7 100644--- a/test/metabase/util/memoize_test.cljc+++ b/test/metabase/util/memoize_test.cljc@@ -60,31 +60,31 @@(deftest ^:parallel fast-interner-test(testing "equal-but-distinct inputs collapse to one identical canonical object,which is the canonicalized form (sorted-map), not the lookup argument"- (let [intern (memo/fast-interner #(into (sorted-map) %))- in1 {:b 2 :a 1} ; hash-map- in2 {:a 1 :b 2}] ; = in1, distinct object- (is (not (identical? in1 in2))) ; genuinely distinct inputs- (is (= in1 (intern in1))) ; value equality preserved- (is (sorted? (intern in1))) ; canonical form returned, not the input hash-map- (is (identical? (intern in1) (intern in2))))) ; equal inputs share the one canonical object+ (let [interner (memo/fast-interner #(into (sorted-map) %))+ in1 {:b 2 :a 1} ; hash-map+ in2 {:a 1 :b 2}] ; = in1, distinct object+ (is (not (identical? in1 in2))) ; genuinely distinct inputs+ (is (= in1 (interner in1))) ; value equality preserved+ (is (sorted? (interner in1))) ; canonical form returned, not the input hash-map+ (is (identical? (interner in1) (interner in2))))) ; equal inputs share the one canonical object(testing "the zero-arg arity interns values as-is"- (let [intern (memo/fast-interner)]- (is (= :kw (intern :kw)))- (is (identical? (intern :kw) (intern :kw)))))+ (let [interner (memo/fast-interner)]+ (is (= :kw (interner :kw)))+ (is (identical? (interner :kw) (interner :kw)))))(testing "nil is returned unchanged without calling the canonicalizer"- (let [calls (atom 0)- intern (memo/fast-interner (fn [x]- (swap! calls inc)- x))]- (is (nil? (intern nil)))+ (let [calls (atom 0)+ interner (memo/fast-interner (fn [x]+ (swap! calls inc)+ x))]+ (is (nil? (interner nil)))(is (zero? @calls))))(testing "a cached false counts as a hit, not a miss"- (let [calls (atom 0)- intern (memo/fast-interner (fn [x]- (swap! calls inc)- x))]- (is (false? (intern false)))- (is (false? (intern false)))+ (let [calls (atom 0)+ interner (memo/fast-interner (fn [x]+ (swap! calls inc)+ x))]+ (is (false? (interner false)))+ (is (false? (interner false)))(is (= 1 @calls)))))(deftest ^:parallel bounded-evicts-when-keyspace-overflows-testdiff --git a/test/metabase/util_test.cljc b/test/metabase/util_test.cljcindex c5476d6032a..6d58ef05537 100644--- a/test/metabase/util_test.cljc+++ b/test/metabase/util_test.cljc@@ -591,10 +591,10 @@Month/MAY 23))))(testing "checks for type of cases"- (is (thrown? Exception #"`case-enum` only works.*"- (u/case-enum Month/JANUARY- Month/JANUARY 1- DayOfWeek/SUNDAY 2))))))+ (is (thrown-with-msg? Exception #"`case-enum` only works.*"+ (u/case-enum Month/JANUARY+ Month/JANUARY 1+ DayOfWeek/SUNDAY 2))))))(deftest ^:parallel truncate-string-to-byte-count-test(letfn [(truncate-string-to-byte-count [s byte-length]diff --git a/test/metabase/xrays/api/automagic_dashboards_test.clj b/test/metabase/xrays/api/automagic_dashboards_test.cljindex bf4fd1c7b52..7e1ef03b426 100644--- a/test/metabase/xrays/api/automagic_dashboards_test.clj+++ b/test/metabase/xrays/api/automagic_dashboards_test.clj@@ -650,7 +650,7 @@(testing schema(let [pattern (:api/regex (mc/properties (mr/resolve-schema schema)))](assert (instance? java.util.regex.Pattern pattern))- (is (re= pattern "0IjoieWVhciJ9XV19LCJkYXRhYmFzZSI6MX0=")))))))+ (is (re-matches pattern "0IjoieWVhciJ9XV19LCJkYXRhYmFzZSI6MX0=")))))))(deftest ^:parallel cell-query-decode-strips-extra-properties-test(testing "the ::cell-query schema decodes a base64 JSON filter clause, validates it, and strips undeclared properties"diff --git a/test_resources/eastwood-config.clj b/test_resources/eastwood-config.cljdeleted file mode 100644index 11de50670a1..00000000000--- a/test_resources/eastwood-config.clj+++ /dev/null@@ -1,87 +0,0 @@-(disable-warning- {:linter :wrong-arity- :function-symbol 'metabase.test.data.users/user-http-request- :arglists-for-linting '([& args])})--(disable-warning- {:linter :wrong-arity- :function-symbol 'metabase.test/user-http-request- :arglists-for-linting '([& args])})--(disable-warning- {:linter :wrong-arity- :function-symbol 'metabase.test.fixtures/initialize- :arglists-for-linting '([& what])})--(disable-warning- {:linter :wrong-arity- :function-symbol 'metabase.test.initialize/initialize-if-needed!- :arglists-for-linting '([& what])})--(disable-warning- {:linter :wrong-arity- :function-symbol 'metabase.test/initialize-if-needed!- :arglists-for-linting '([& what])})--(disable-warning- {:linter :wrong-arity- :function-symbol 'metabase.query-processor-test/normal-drivers-with-feature- :arglists-for-linting '([feature & more-features])})--(disable-warning- {:linter :wrong-arity- :function-symbol 'metabase.test/normal-drivers-with-feature- :arglists-for-linting '([feature & more-features])})--(disable-warning- {:linter :wrong-arity- :function-symbol 'metabase.query-processor-test/normal-drivers-without-feature- :arglists-for-linting '([feature & more-features])})--(disable-warning- {:linter :wrong-arity- :function-symbol 'metabase.test/normal-drivers-without-feature- :arglists-for-linting '([feature & more-features])})--(disable-warning- {:linter :wrong-arity- :function-symbol 'metabase.test.http-client/client- :arglists-for-linting '([& args])})--(disable-warning- {:linter :wrong-arity- :function-symbol 'metabase.test/client- :arglists-for-linting '([& args])})--(disable-warning- {:linter :wrong-arity- :function-symbol 'metabase.test.http-client/client-full-response- :arglists-for-linting '([& args])})--(disable-warning- {:linter :wrong-arity- :function-symbol 'metabase.test/client-full-response- :arglists-for-linting '([& args])})--(disable-warning- {:linter :wrong-arity- :function-symbol 'metabase.test.data.sql/qualified-name-components- :arglists-for-linting '([driver database-name & args])})--(disable-warning- {:linter :suspicious-expression- :for-macro 'clojure.core/let- :if-inside-macroexpansion-of #{'metabase.collections.models.collection-test/with-collection-in-location}- :within-depth 10})--(disable-warning- {:linter :suspicious-expression- :for-macro 'clojure.core/let- :if-inside-macroexpansion-of '#{metabase.test/with-temp- metabase.test/with-temp*}- :within-depth 10})--(disable-warning- {:linter :constant-test- :if-inside-macroexpansion-of #{'clojure.java.jdbc/with-db-connection}- :within-depth 5})diff --git a/test_resources/eastwood_config.clj b/test_resources/eastwood_config.cljnew file mode 100644index 00000000000..93868915f05--- /dev/null+++ b/test_resources/eastwood_config.clj@@ -0,0 +1,15 @@+;; Extra Eastwood config, loaded by `metabase.linters.eastwood`.++;; Kondo's `:deprecated-var` linter checks our own deprecated vars, with its exceptions in `.clj-kondo/config.edn`.+;; Eastwood only needs to flag deprecated Java and library calls, which Kondo can't see.+#_{:clj-kondo/ignore [:unresolved-symbol]}+(disable-warning+ {:linter :deprecations+ :symbol-matches #{#"^#'metabase(-enterprise)?\."}})++;; `(is (thrown? ...))` expands to a `try` whose body is evaluated only to see whether it throws.+#_{:clj-kondo/ignore [:unresolved-symbol]}+(disable-warning+ {:linter :unused-ret-vals-in-try+ :if-inside-macroexpansion-of #{'clojure.test/is}+ :within-depth 10})