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 the code review findings of the closed argument schemas PR (#82537)
Alexander Polyankin48d493c2930a
diff --git a/enterprise/backend/src/metabase_enterprise/audit_app/query_processor/middleware/handle_audit_queries.clj b/enterprise/backend/src/metabase_enterprise/audit_app/query_processor/middleware/handle_audit_queries.cljindex 674e7c20577..3c353372fb3 100644--- a/enterprise/backend/src/metabase_enterprise/audit_app/query_processor/middleware/handle_audit_queries.clj+++ b/enterprise/backend/src/metabase_enterprise/audit_app/query_processor/middleware/handle_audit_queries.clj@@ -104,7 +104,8 @@[:limit {:optional true} [:maybe ms/IntGreaterThanOrEqualToZero]][:offset {:optional true} [:maybe ms/IntGreaterThanOrEqualToZero]][:info {:optional true} [:maybe :metabase.lib.schema.info/info]]- [:middleware {:optional true} [:maybe :metabase.lib.schema.middleware-options/middleware-options]]]]]+ [:middleware {:optional true} [:maybe :metabase.lib.schema.middleware-options/middleware-options]]+ [:viz-settings {:optional true} [:maybe ms/VisualizationSettings]]]]]config/is-test?(conj [::mc/default[:map {:closed true}@@ -114,7 +115,8 @@[:limit {:optional true} [:maybe ms/IntGreaterThanOrEqualToZero]][:offset {:optional true} [:maybe ms/IntGreaterThanOrEqualToZero]][:info {:optional true} [:maybe :metabase.lib.schema.info/info]]- [:middleware {:optional true} [:maybe :metabase.lib.schema.middleware-options/middleware-options]]]]))))+ [:middleware {:optional true} [:maybe :metabase.lib.schema.middleware-options/middleware-options]]+ [:viz-settings {:optional true} [:maybe ms/VisualizationSettings]]]]))))(defn- validate-internal-query[query]diff --git a/enterprise/backend/src/metabase_enterprise/data_complexity_score/schema.clj b/enterprise/backend/src/metabase_enterprise/data_complexity_score/schema.cljindex ca7373c45f8..75d12818d4b 100644--- a/enterprise/backend/src/metabase_enterprise/data_complexity_score/schema.clj+++ b/enterprise/backend/src/metabase_enterprise/data_complexity_score/schema.clj@@ -42,12 +42,12 @@[:formula-version :int][:format-version :int][:synonym-threshold number?]- [:weights [:map {:closed true}- [:entity :int]- [:name-collision :int]- [:synonym-pair :int]- [:field :int]- [:repeated-measure :int]]]+ [:weights {:optional true} [:map {:closed true}+ [:entity :int]+ [:name-collision :int]+ [:synonym-pair :int]+ [:field :int]+ [:repeated-measure :int]]][:embedding-model {:optional true} [:maybe [:map {:closed true}[:provider [:maybe [:or :string :keyword]]][:model-name [:maybe :string]]diff --git a/enterprise/backend/test/metabase_enterprise/audit_app/query_processor/middleware/handle_audit_queries_test.clj b/enterprise/backend/test/metabase_enterprise/audit_app/query_processor/middleware/handle_audit_queries_test.cljindex cb110d8a6ee..c6c55a2a467 100644--- a/enterprise/backend/test/metabase_enterprise/audit_app/query_processor/middleware/handle_audit_queries_test.clj+++ b/enterprise/backend/test/metabase_enterprise/audit_app/query_processor/middleware/handle_audit_queries_test.clj@@ -1,6 +1,7 @@(ns metabase-enterprise.audit-app.query-processor.middleware.handle-audit-queries-test"Additional tests for this namespace can be found in `metabase-enterprise.audit-app.pages-test`."(:require+ [clojure.data.csv :as csv][clojure.test :refer :all][metabase-enterprise.audit-app.interface :as audit.i][metabase.query-processor.test :as qp]@@ -45,3 +46,18 @@(testing "rows"(is (= expected-rows(mt/rows @results)))))))))++(defmethod audit.i/internal-query ::export-query-fn+ [_]+ {:metadata [[:title {:display_name "Title", :base_type :type/Text}]+ [:count {:display_name "Count", :base_type :type/Integer}]]+ :results [{:title "Birds", :count 2}+ {:title "Cans", :count 3}]})++(deftest export-internal-query-test+ (testing "POST /api/dataset/:export-format downloads the results of an internal query"+ (mt/with-premium-features #{:audit-app}+ (is (= [["Birds" "2"] ["Cans" "3"]]+ (rest (csv/read-csv (mt/user-http-request :crowberto :post 200 "dataset/csv"+ {:query {:type "internal"+ :fn (u/qualified-name ::export-query-fn)}}))))))))diff --git a/enterprise/backend/test/metabase_enterprise/data_complexity_score/complexity_test.clj b/enterprise/backend/test/metabase_enterprise/data_complexity_score/complexity_test.cljindex 77a30cfc7bc..2a1dd598161 100644--- a/enterprise/backend/test/metabase_enterprise/data_complexity_score/complexity_test.clj+++ b/enterprise/backend/test/metabase_enterprise/data_complexity_score/complexity_test.clj@@ -1209,6 +1209,21 @@(finally(t2/delete! :model/DataComplexityScore :fingerprint [:in [other-fingerprint fingerprint]]))))))+(deftest ^:synchronized record-score-persists-an-appdb-score-test+ (testing "the score `complexity-scores` computes against the app DB, whose `:meta` carries no `:weights`, persists"+ (mt/initialize-if-needed! :db)+ (let [fingerprint "record-score-appdb-test/current"]+ (try+ (t2/delete! :model/DataComplexityScore :fingerprint fingerprint)+ (let [result (complexity/complexity-scores :embedder nil :emit-snowplow? false)+ stored (data-complexity-score/record-score! fingerprint "appdb" result)]+ (is (not (contains? (:meta result) :weights)))+ (is (= (select-keys result [:library :universe :metabot])+ (select-keys stored [:library :universe :metabot])))+ (is (= (:meta result) (dissoc (:meta stored) :calculated-at))))+ (finally+ (t2/delete! :model/DataComplexityScore :fingerprint fingerprint))))))+(deftest ^:synchronized latest-score-filters-by-source-test(testing "passing source filters out representation-derived rows that share the cron's fingerprint";; The CLI's representation mode writes under the same `task.complexity-score/current-fingerprint`diff --git a/enterprise/backend/test/metabase_enterprise/sandbox/query_processor/middleware/sandboxing_test.clj b/enterprise/backend/test/metabase_enterprise/sandbox/query_processor/middleware/sandboxing_test.cljindex 1d34a13e21f..045b96e0964 100644--- a/enterprise/backend/test/metabase_enterprise/sandbox/query_processor/middleware/sandboxing_test.clj+++ b/enterprise/backend/test/metabase_enterprise/sandbox/query_processor/middleware/sandboxing_test.clj@@ -1809,6 +1809,27 @@(<= 1 day-int 31))))(next result))))))))))+(deftest temporal-bucketing-and-binning-breakouts-test+ (testing "A sandboxed user can break out by a temporal bucket and a binned column, and gets the unsandboxed column metadata"+ (mt/test-drivers (into #{} (filter (mt/normal-drivers-with-feature :binning)) (e2e-test-drivers))+ (met/with-gtaps! {:gtaps {:orders {:remappings {"user_id" ["variable" [:field (mt/id :orders :user_id) nil]]}}}+ :attributes {"user_id" 1}}+ (let [mp (mt/metadata-provider)+ query (-> (lib/query mp (lib.metadata/table mp (mt/id :orders)))+ (lib/aggregate (lib/count))+ (lib/breakout (lib/with-temporal-bucket (lib.metadata/field mp (mt/id :orders :created_at)) :year))+ (lib/breakout (lib/with-binning (lib.metadata/field mp (mt/id :orders :total))+ {:strategy :num-bins, :num-bins 10})))+ expected (mt/with-test-user :crowberto+ (qp/process-query (lib/filter query (lib/= (lib.metadata/field mp (mt/id :orders :user_id)) 1))))+ result (qp/process-query query)]+ (is (true? (-> result :data :is_sandboxed)))+ (is (seq (mt/rows expected)))+ (is (= (mt/rows expected)+ (mt/rows result)))+ (is (= (map (juxt :display_name :unit (comp :num_bins :binning_info)) (mt/cols expected))+ (map (juxt :display_name :unit (comp :num_bins :binning_info)) (mt/cols result)))))))))+(deftest sandboxed-join-excludes-hidden-columns-test(testing "When joining to a sandboxed table, hidden columns should not be added to join fields (#64317)"(mt/dataset test-datadiff --git a/enterprise/backend/test/metabase_enterprise/security_center/fetch_test.clj b/enterprise/backend/test/metabase_enterprise/security_center/fetch_test.cljindex c3ef90887a7..be2ce70352c 100644--- a/enterprise/backend/test/metabase_enterprise/security_center/fetch_test.clj+++ b/enterprise/backend/test/metabase_enterprise/security_center/fetch_test.clj@@ -125,6 +125,22 @@(is (= [{:version "0.58.11" :url "https://downloads.example.com/metabase.jar"}](:download_jar_urls row)))))))))+(deftest fetch-advisory-with-unknown-entry-fields-test+ (testing "fields the store adds to version ranges and download JARs don't stop advisory sync"+ (let [advisory (make-json-advisory "SC-DL-002"+ "affected_versions" [{"min" "0.58.0" "fixed" "0.58.11" "cve" "CVE-2026-0001"}]+ "download_jar_urls" [{"version" "0.58.11"+ "url" "https://downloads.example.com/metabase.jar"+ "sha256" "abc123"}])]+ (mt/with-model-cleanup [:model/SecurityAdvisory]+ (with-redefs [http/get (constantly (fake-store-response [advisory]))+ premium-features/premium-embedding-token (constantly "fake-token")+ premium-features/site-uuid-for-premium-features-token-checks (constantly "fake-uuid")]+ (fetch/sync-advisories!)+ (is (=? {:affected_versions [{:min "0.58.0" :fixed "0.58.11"}]+ :download_jar_urls [{:version "0.58.11" :url "https://downloads.example.com/metabase.jar"}]}+ (t2/select-one :model/SecurityAdvisory :advisory_id "SC-DL-002"))))))))+(deftest sync-advisories-stores-updated-at-test(mt/with-model-cleanup [:model/SecurityAdvisory](mt/with-dynamic-fn-redefs [fetch/fetch-advisories-from-storediff --git a/enterprise/backend/test/metabase_enterprise/serialization/v2/e2e_test.clj b/enterprise/backend/test/metabase_enterprise/serialization/v2/e2e_test.cljindex fcb323d2844..1f4b84b4459 100644--- a/enterprise/backend/test/metabase_enterprise/serialization/v2/e2e_test.clj+++ b/enterprise/backend/test/metabase_enterprise/serialization/v2/e2e_test.clj@@ -1043,3 +1043,42 @@(is (=? {:table_id (:id table) :name field-name :active false} field))(is (= (:id table) (lib/primary-source-table-id imported)))(is (=? [[:field {} (:id field)]] (lib/fields imported)))))))++(deftest orphaned-transform-yaml-round-trip-test+ (testing "A Transform whose source database was deleted round-trips through YAML storage as a tombstone"+ (mt/with-premium-features #{:transforms-basic}+ (ts/with-random-dump-dir [dump-dir "serdesv2-"]+ (ts/with-dbs [source-db dest-db]+ (ts/with-db source-db+ (t2/delete! :model/TransformTag)+ (let [db (ts/create! :model/Database :name "soon-to-be-deleted")+ table (ts/create! :model/Table :name "customers" :db_id (:id db))+ mp (lib-be/application-database-metadata-provider (:id db))]+ (ts/create! :model/Transform+ :name "Orphan Transform"+ :source {:type "query"+ :query (lib/query mp (lib.metadata/table mp (:id table)))}+ :target {:database (:id db)+ :type "table"+ :schema "public"+ :name "orphan_target"})+ (t2/delete! :model/Database :id (:id db))+ (storage/store! (serdes/with-cache (into [] (extract/extract {})))+ (storage.files/file-writer dump-dir))))+ (let [file (io/file dump-dir "collections" "transforms" "orphan_transform.yaml")+ exported (yaml/from-file file)]+ (testing "the exported query carries no metadata provider"+ (is (=? {:database nil, :lib/type "mbql/query"} (get-in exported [:source :query])))+ (is (not (contains? (get-in exported [:source :query]) :lib/metadata))))+ (dump/spit-yaml! file (assoc-in exported [:source :query :lib/metadata] nil)))+ (ts/with-db dest-db+ (t2/delete! :model/TransformTag)+ (is (serdes/with-cache (serdes.load/load-metabase! (ingest/ingest-yaml dump-dir)))+ "an export written with a nil `lib/metadata` still loads")+ (let [transform (t2/select-one :model/Transform :name "Orphan Transform")]+ (is (=? {:source_database_id nil+ :source {:type :query}}+ transform))+ (is (=? {"database" nil+ "stages" [{"source-table" pos-int?}]}+ (get-in transform [:source :query]))))))))))diff --git a/enterprise/backend/test/metabase_enterprise/sso/integrations/jwt_test.clj b/enterprise/backend/test/metabase_enterprise/sso/integrations/jwt_test.cljindex 3385a3e2834..16ffb146800 100644--- a/enterprise/backend/test/metabase_enterprise/sso/integrations/jwt_test.clj+++ b/enterprise/backend/test/metabase_enterprise/sso/integrations/jwt_test.clj@@ -14,6 +14,7 @@[metabase.appearance.settings :as appearance.settings][metabase.auth-identity.provider :as auth-identity.provider][metabase.test :as mt]+ [metabase.test.data.users :as test.users][metabase.test.fixtures :as fixtures][metabase.test.http-client :as client][metabase.util :as u]@@ -239,6 +240,22 @@(= {"extra" "keypairs", "are" "also present"}(t2/select-one-fn :jwt_attributes :model/User :email "[email protected]"))))))))+(deftest login-with-existing-session-test+ (testing "a JWT login from a client that already carries a Metabase session succeeds"+ (with-jwt-default-setup!+ (let [response (client/client-real-response (test.users/username->token :rasta)+ :get 302 "/auth/sso" {:request-options {:redirect-strategy :none}}+ :return_to default-redirect-uri+ :jwt+ (jwt/sign+ {:email "[email protected]"+ :first_name "Rasta"+ :last_name "Toucan"}+ default-jwt-secret))]+ (is (sso.test-setup/successful-login? response))+ (is (= default-redirect-uri+ (get-in response [:headers "Location"])))))))+(deftest request-jwt-test(let [token "some.jwt.token"](testing "GET reads jwt from query params"diff --git a/src/metabase/auth_identity/provider.clj b/src/metabase/auth_identity/provider.cljindex 7ac81d5df6c..12097a9e8d7 100644--- a/src/metabase/auth_identity/provider.clj+++ b/src/metabase/auth_identity/provider.clj@@ -61,6 +61,7 @@[metabase.events.core :as events][metabase.notification.core :as notification][metabase.premium-features.core :refer [defenterprise]]+ [metabase.request.schema :as request.schema][metabase.users.schema :as users.schema][metabase.util :as u][metabase.util.i18n :refer [deferred-tru]]@@ -279,69 +280,32 @@[:tenant_id {:optional true} [:maybe ms/PositiveInt]][:groups {:optional true} [:maybe [:sequential :string]]]])-(def ^:private CookieAttrs- "One `:cookies` entry of a Ring request: a cookie's value and its attributes."- [:map {:closed true}- [:value {:optional true} :string]- [:path {:optional true} :string]- [:domain {:optional true} :string]- [:max-age {:optional true} :int]- [:secure {:optional true} :boolean]- [:http-only {:optional true} :boolean]])-(def ^:private login-pipeline-entries- "Malli map entries shared by the login pipeline map threaded through [[apply-inactive-check]] and- [[create-session!]]: the raw Ring request keys plus every provider's request/result extension keys."- [[:accept {:optional true} [:maybe :string]]- [:auth-identity {:optional true} [:maybe ::auth-identity.schema/auth-identity]]+ "Malli map entries every provider adds to the Ring request threaded through [[apply-inactive-check]] and+ [[create-session!]] as the login pipeline map."+ [[:auth-identity {:optional true} [:maybe ::auth-identity.schema/auth-identity]][:authenticated-user {:optional true} [:maybe (ms/InstanceOfClass clojure.lang.IDeref)]]- [:body {:optional true} [:maybe [:or ms/RingRequestBody (ms/InstanceOfClass java.io.InputStream)]]]- [:browser-id {:optional true} [:maybe :string]]- [:character-encoding {:optional true} [:maybe :string]][:claims {:optional true} [:maybe ms/JWTClaims]][:code {:optional true} [:maybe :string]]- [:content-length {:optional true} [:maybe :int]]- [:content-type {:optional true} [:maybe :string]]- [:cookies {:optional true} [:maybe [:map-of :string CookieAttrs]]][:device-info {:optional true} [:maybe DeviceInfo]][:email {:optional true} [:maybe :string]][:error {:optional true} [:maybe :keyword]]- [:form-params {:optional true} [:maybe [:map-of :string [:or :string [:sequential :string]]]]]- [:headers {:optional true} [:maybe [:map-of :string :string]]][:jwt-data {:optional true} [:maybe ms/JWTClaims]][:message {:optional true} [:maybe [:or :string ms/LocalizedString]]]- [:nonce {:optional true} [:maybe :string]][:oidc-nonce {:optional true} [:maybe :string]][:oidc-provider {:optional true} [:maybe :keyword]][:oidc-provider-key {:optional true} [:maybe :string]]- [:params {:optional true} [:maybe ms/RingRequestParams]][:password {:optional true} [:maybe :string]]- [:path-info {:optional true} [:maybe :string]]- [:protocol {:optional true} [:maybe :string]][:provider-id {:optional true} [:maybe :string]]- [:query-params {:optional true} [:maybe [:map-of :string [:or :string [:sequential :string]]]]]- [:query-string {:optional true} [:maybe :string]]- [:redirect-strategy {:optional true} [:maybe :keyword]][:redirect-uri {:optional true} [:maybe :string]][:redirect-url {:optional true} [:maybe :string]]- [:remote-addr {:optional true} [:maybe :string]]- [:request-id {:optional true} [:maybe (ms/InstanceOfClass java.util.UUID)]]- [:request-method {:optional true} [:maybe :keyword]]- [:route-metadata {:optional true} [:maybe :metabase.api.macros/route-metadata]]- [:route-params {:optional true} [:maybe ms/RingRequestParams]][:saml-data {:optional true} [:maybe ms/SAMLAttributes]]- [:scheme {:optional true} [:maybe :keyword]]- [:server-name {:optional true} [:maybe :string]]- [:server-port {:optional true} [:maybe :int]][:slack-data {:optional true} [:maybe [:map-of :string :string]]]- [:ssl-client-cert {:optional true} [:maybe (ms/InstanceOfClass java.security.cert.X509Certificate)]][:state {:optional true} [:maybe :string]][:success? {:optional true} [:maybe [:or :boolean [:enum :redirect]]]][:tenant-attributes {:optional true} [:maybe ms/TenantAttributes]][:tenant-slug {:optional true} [:maybe :string]][:token {:optional true} [:maybe :string]]- [:token-exchange? {:optional true} :boolean]- [:uri {:optional true} [:maybe :string]][:user-data {:optional true} [:maybe UserData]][:user-id {:optional true} [:maybe :int]][:user-provisioning-enabled? {:optional true} [:maybe :boolean]]@@ -352,9 +316,11 @@If the user does not have `:is_active true`, the response is not successful and an error message is returned. Arequest that resolved no user at all is left alone: link-only flows legitimately finish without one."- [request :- (into [:map {:closed true}- [:user {:optional true} [:maybe ::users.schema/user]]]- login-pipeline-entries)]+ [request :- [:merge+ ::request.schema/request+ (into [:map {:closed true}+ [:user {:optional true} [:maybe ::users.schema/user]]]+ login-pipeline-entries)]](cond-> request(and (nil? (:error request))(:user request)@@ -365,9 +331,11 @@(mu/defn- create-session!"Create a new session for a user with the given provider.Updates the last_used_at timestamp on the corresponding AuthIdentity."- [request :- (into [:map {:closed true}- [:user ::users.schema/user]]- login-pipeline-entries)+ [request :- [:merge+ ::request.schema/request+ (into [:map {:closed true}+ [:user ::users.schema/user]]+ login-pipeline-entries)]provider :- :keyword](if-not (get-in request [:user :is_active])(assoc request :success? falsediff --git a/src/metabase/batch_processing/impl.clj b/src/metabase/batch_processing/impl.cljindex ce3093d2788..2bdf137dbaf 100644--- a/src/metabase/batch_processing/impl.clj+++ b/src/metabase/batch_processing/impl.clj@@ -109,7 +109,7 @@[:map {:closed true}[:user-id ms/PositiveInt][:dashboard-id ms/PositiveInt]- [:parameters [:sequential :metabase.parameters.schema/parameter-with-value]]]+ [:parameters [:sequential :metabase.parameters.schema/parameter-with-stored-value]]][:map {:closed true}[:user-id ms/PositiveInt][:model [:enum :model/Card :model/Table :model/Dashboard :model/Collection :model/Document]]diff --git a/src/metabase/channel/render/body.clj b/src/metabase/channel/render/body.cljindex 035dda3e17f..4450796681e 100644--- a/src/metabase/channel/render/body.clj+++ b/src/metabase/channel/render/body.clj@@ -25,6 +25,7 @@[metabase.pivot.postprocess :as pivot.postprocess][metabase.query-processor.compile :as qp.compile][metabase.query-processor.pivot]+ [metabase.query-processor.schema :as qp.schema][metabase.query-processor.streaming :as qp.streaming][metabase.query-processor.streaming.common :as streaming.common][metabase.tiles.settings :as tiles.settings]@@ -168,29 +169,31 @@[:unit {:optional true} [:maybe :keyword]]])(mr/def ::QPResultData- "The `:data` of a QP result, as the render pipeline reads it."- [:map {:closed true}- [:cols {:optional true} [:maybe [:sequential :metabase.legacy-mbql.schema/legacy-column-metadata]]]- [:rows {:optional true} [:maybe [:sequential [:sequential [:or ms/FieldValue [:sequential ms/FieldValue]]]]]]- [:viz-settings {:optional true} [:maybe ms/VisualizationSettings]]- [:results_metadata {:optional true} [:maybe [:map {:closed true}- [:columns [:sequential :metabase.legacy-mbql.schema/legacy-column-metadata]]]]]- [:results_timezone {:optional true} [:maybe :string]]- [:format-rows? {:optional true} [:maybe :boolean]]- [:native_form {:optional true} [:maybe ::qp.compile/compiled]]- [:insights {:optional true} [:maybe [:sequential Insight]]]- [:rows_truncated {:optional true} [:maybe :int]]- [:csv-include-bom? {:optional true} [:maybe :boolean]]- [:rows-file-size {:optional true} [:maybe :int]]- [:model {:optional true} [:maybe :boolean]]- [:dataset {:optional true} [:maybe :boolean]]- [:pivot-export-options {:optional true} [:maybe [:map {:closed true}- [:pivot-rows {:optional true} [:maybe [:sequential :int]]]- [:pivot-cols {:optional true} [:maybe [:sequential :int]]]- [:pivot-measures {:optional true} [:maybe [:sequential :int]]]- [:show-row-totals {:optional true} :boolean]- [:show-column-totals {:optional true} :boolean]- [:column-sort-order {:optional true} [:maybe :metabase.query-processor.pivot/column-sort-order]]]]]])+ "The `:data` of a QP result, as the render pipeline reads it: the query processor's result metadata plus the rows."+ [:merge+ ::qp.schema/metadata+ [:map {:closed true}+ [:cols {:optional true} [:maybe [:sequential :metabase.legacy-mbql.schema/legacy-column-metadata]]]+ [:rows {:optional true} [:maybe [:sequential [:sequential [:or ms/FieldValue [:sequential ms/FieldValue]]]]]]+ [:viz-settings {:optional true} [:maybe ms/VisualizationSettings]]+ [:results_metadata {:optional true} [:maybe [:map {:closed true}+ [:columns [:sequential :metabase.legacy-mbql.schema/legacy-column-metadata]]]]]+ [:results_timezone {:optional true} [:maybe :string]]+ [:format-rows? {:optional true} [:maybe :boolean]]+ [:native_form {:optional true} [:maybe ::qp.compile/compiled]]+ [:insights {:optional true} [:maybe [:sequential Insight]]]+ [:rows_truncated {:optional true} [:maybe :int]]+ [:csv-include-bom? {:optional true} [:maybe :boolean]]+ [:rows-file-size {:optional true} [:maybe :int]]+ [:model {:optional true} [:maybe :boolean]]+ [:dataset {:optional true} [:maybe :boolean]]+ [:pivot-export-options {:optional true} [:maybe [:map {:closed true}+ [:pivot-rows {:optional true} [:maybe [:sequential :int]]]+ [:pivot-cols {:optional true} [:maybe [:sequential :int]]]+ [:pivot-measures {:optional true} [:maybe [:sequential :int]]]+ [:show-row-totals {:optional true} :boolean]+ [:show-column-totals {:optional true} :boolean]+ [:column-sort-order {:optional true} [:maybe :metabase.query-processor.pivot/column-sort-order]]]]]]])(mr/def ::QPResult"A QP result map (`{:data ..., :error ...}`), as the render pipeline receives it."diff --git a/src/metabase/channel/slack.clj b/src/metabase/channel/slack.cljindex 99967be45f0..31027e95957 100644--- a/src/metabase/channel/slack.clj+++ b/src/metabase/channel/slack.clj@@ -366,26 +366,8 @@(complete-upload! file filename {:channel-id target} initial-comment))))))(mr/def ::slack-block- "A Slack Block Kit block, element, or legacy `attachments` entry -- self-similar and recursive (blocks nest- elements, elements nest elements, and `:text`/`:accessory` nest another block-shaped object).- See https://api.slack.com/block-kit."- [:map {:closed true}- [:type {:optional true} [:maybe :string]]- [:text {:optional true} [:maybe [:or :string [:ref ::slack-block]]]]- [:fields {:optional true} [:maybe [:sequential [:ref ::slack-block]]]]- [:elements {:optional true} [:maybe [:sequential [:ref ::slack-block]]]]- [:accessory {:optional true} [:maybe [:ref ::slack-block]]]- [:block_id {:optional true} [:maybe :string]]- [:image_url {:optional true} [:maybe :string]]- [:alt_text {:optional true} [:maybe :string]]- [:emoji {:optional true} [:maybe :boolean]]- [:color {:optional true} [:maybe :string]]- [:pretext {:optional true} [:maybe :string]]- [:title {:optional true} [:maybe :string]]- [:author_name {:optional true} [:maybe :string]]- [:footer {:optional true} [:maybe :string]]- [:fallback {:optional true} [:maybe :string]]- [:ts {:optional true} [:maybe [:or :string number?]]]])+ "A Slack Block Kit block or legacy `attachments` entry, whose keys are Slack's (see https://api.slack.com/block-kit)."+ [:map {:closed false, ::mr/deliberately-open true, :description "Slack Block Kit block"}])(mu/defn post-chat-message!"Calls Slack API `chat.postMessage` endpoint and posts a message to a channel.diff --git a/src/metabase/embedding_rest/api/embed.clj b/src/metabase/embedding_rest/api/embed.cljindex ab9a0bd4c23..8b8428b2ccf 100644--- a/src/metabase/embedding_rest/api/embed.clj+++ b/src/metabase/embedding_rest/api/embed.clj@@ -103,7 +103,7 @@:card card:token-params (embedding.jwt/get-in-unsigned-token-or-throw unsigned-token [:params]):embedding-params (:embedding_params card)- :query-params (api.embed.common/parse-query-params (dissoc query-params :format_rows :pivot_results))+ :query-params query-params:qp qp:constraints constraints:options options)))@@ -202,7 +202,7 @@:card card:embedding-params (:embedding_params dashboard):token-params (embedding.jwt/get-in-unsigned-token-or-throw unsigned-token [:params])- :query-params (api.embed.common/parse-query-params (dissoc query-params :format_rows :pivot_results))+ :query-params query-params:constraints constraints:qp qp:middleware middleware)))diff --git a/src/metabase/legacy_mbql/schema.cljc b/src/metabase/legacy_mbql/schema.cljcindex b170690793e..ba3dde4fa40 100644--- a/src/metabase/legacy_mbql/schema.cljc+++ b/src/metabase/legacy_mbql/schema.cljc@@ -52,6 +52,35 @@(when-let [tag (helpers/effective-clause-tag x)](keyword "metabase.legacy-mbql.schema" (name tag)))))+(defn- normalize-dropping-undeclared-keys+ "A `:decode/normalize` interceptor for a closed clause options map that applies `normalize-fn` and drops the keys the map does not declare."+ [normalize-fn]+ {:compile (fn [schema _options]+ (let [declared-keys (set (mc/explicit-keys schema))]+ (fn [m]+ (when-let [m (normalize-fn m)]+ (reduce-kv (fn [m k _v]+ (cond-> m+ (not (contains? declared-keys k)) (dissoc k)))+ m+ m)))))})++(def ^:private common-clause-option-entries+ "The entries of `:metabase.lib.schema.common/options` that converting any MBQL 5 clause to legacy MBQL can leave in its options: the type and name keys and the query processor's internal keys."+ (into []+ (filter (fn [[k]]+ (or (lib.schema.common/internal-key? k)+ (contains? #{:base-type :effective-type :semantic-type :database-type :name :display-name} k))))+ (-> (mc/schema ::lib.schema.common/options) mc/deref-all mc/children first mc/children)))++(defn- with-common-clause-option-entries+ "Add the [[common-clause-option-entries]] that closed map schema `map-schema` does not declare itself."+ [[tag properties & entries :as _map-schema]]+ (let [own-keys (into #{} (map first) entries)]+ (-> [tag properties]+ (into (remove (comp own-keys first)) common-clause-option-entries)+ (into entries))))+(defn- normalize-mbql-clause [x](when-let [schema (infer-mbql-clause-schema x)](lib.normalize/normalize schema x)))@@ -254,9 +283,10 @@(mr/def ::ValueTypeInfo[:map- {:closed true, :decode/normalize (fn [m]- (when (map? m)- (update-keys m (comp keyword u/->snake_case_en))))+ {:closed true, :decode/normalize (normalize-dropping-undeclared-keys+ (fn [m]+ (when (map? m)+ (update-keys m (comp keyword u/->snake_case_en))))):description (str "Type info about a value in a `:value` clause. Added automatically by `wrap-value-literals`"" middleware to values in filter clauses based on the Field in the clause.")}[:database_type {:optional true} [:maybe ::lib.schema.common/non-blank-string]]@@ -826,8 +856,9 @@lib.schema.expression.temporal/datetime-modes))(mr/def ::DatetimeOptions- [:map {:closed true, :decode/normalize lib.schema.common/normalize-map}- [:mode {:optional true} [:ref ::DatetimeOptionsMode]]])+ (with-common-clause-option-entries+ [:map {:closed true, :decode/normalize (normalize-dropping-undeclared-keys lib.schema.common/normalize-map)}+ [:mode {:optional true} [:ref ::DatetimeOptionsMode]]]))(defclause datetimevalue [:ref ::ExpressionArg]@@ -1081,10 +1112,11 @@(defclause not-empty field [:ref ::Emptyable])(mr/def ::StringFilterOptions- [:map- {:closed true, :decode/normalize lib.schema.common/normalize-map}- ;; default true- [:case-sensitive {:optional true} :boolean]])+ (with-common-clause-option-entries+ [:map+ {:closed true, :decode/normalize (normalize-dropping-undeclared-keys lib.schema.common/normalize-map)}+ ;; default true+ [:case-sensitive {:optional true} :boolean]]))(doseq [clause-keyword [::starts-with ::ends-with ::contains ::does-not-contain]](defmethod options-style-method (keyword (name clause-keyword)) [_tag] ::options-style.𝕨𝕚𝕝𝕕)@@ -1104,11 +1136,12 @@"more-strings-or-fields" [:rest [:ref ::StringExpressionArg]])]))(mr/def ::TimeIntervalOptions- [:map- {:closed true, :decode/normalize lib.schema.common/normalize-map}- ;; Should we include partial results for the current day/month/etc? Defaults to `false`; set this to `true` to- ;; include them.- [:include-current {:optional true} :boolean]])+ (with-common-clause-option-entries+ [:map+ {:closed true, :decode/normalize (normalize-dropping-undeclared-keys lib.schema.common/normalize-map)}+ ;; Should we include partial results for the current day/month/etc? Defaults to `false`; set this to `true` to+ ;; include them.+ [:include-current {:optional true} :boolean]]));; Filter subclause. Syntactic sugar for specifying a specific time interval.;;@@ -1208,10 +1241,11 @@[:sequential {:min 1} ::CaseSubclause])(mr/def ::CaseOptions- [:map- {:closed true, :decode/normalize lib.schema.common/normalize-map- :error/message ":case options"}- [:default {:optional true} [:ref ::ExpressionArg]]])+ (with-common-clause-option-entries+ [:map+ {:closed true, :decode/normalize (normalize-dropping-undeclared-keys lib.schema.common/normalize-map)+ :error/message ":case options"}+ [:default {:optional true} [:ref ::ExpressionArg]]]))(defclause caseclauses [:ref ::CaseSubclauses], options (optional [:ref ::CaseOptions]))@@ -1371,19 +1405,19 @@(mr/def ::AggregationOptionsOptions"Additional options for any aggregation clause when wrapping it in `:aggregation-options`."- [:map- {:closed true, :error/message ":aggregation-options options"- :decode/normalize (fn [m]- (let [m (if (nil? m)- {}- m)]- (lib.schema.common/normalize-map m)))}- ;; name to use for this aggregation in the native query instead of the default name (e.g. `count`)- [:name {:optional true} ::lib.schema.common/non-blank-string]- ;; user-facing display name for this aggregation instead of the default one- [:display-name {:optional true} ::lib.schema.common/non-blank-string]- [:metabase.query-processor.util.add-alias-info/source-alias {:optional true} [:maybe :string]]- [:metabase.query-processor.util.add-alias-info/desired-alias {:optional true} [:maybe :string]]])+ (with-common-clause-option-entries+ [:map+ {:closed true, :error/message ":aggregation-options options"+ :decode/normalize (normalize-dropping-undeclared-keys+ (fn [m]+ (let [m (if (nil? m)+ {}+ m)]+ (lib.schema.common/normalize-map m))))}+ ;; name to use for this aggregation in the native query instead of the default name (e.g. `count`)+ [:name {:optional true} ::lib.schema.common/non-blank-string]+ ;; user-facing display name for this aggregation instead of the default one+ [:display-name {:optional true} ::lib.schema.common/non-blank-string]]))(defclause* aggregation-options[:anddiff --git a/src/metabase/legacy_mbql/util.cljc b/src/metabase/legacy_mbql/util.cljcindex bdd442fe10e..675e40f3129 100644--- a/src/metabase/legacy_mbql/util.cljc+++ b/src/metabase/legacy_mbql/util.cljc@@ -201,10 +201,11 @@"Like [[clojure.core/update]], but for the options in a `:field`, `:expression`, or `:aggregation` clause.DEPRECATED: Use MBQL 5 + [[metabase.lib.core/update-options]] going forward."- {:arglists '([field-or-ag-ref-or-expression-ref f]), :deprecated "0.57.0"}+ {:arglists '([field-or-ag-ref-or-expression-ref f & args]), :deprecated "0.57.0"}[[clause-type id-or-name opts] :- ::mbql.s/Reference- f :- ifn?]- (let [opts (not-empty (remove-empty (f opts)))]+ f :- ifn?+ & args :- [:* [:or ::lib.schema.common/clause-arg fn?]]]+ (let [opts (not-empty (remove-empty (apply f opts args)))];; `:field` clauses should have a `nil` options map if there are no options. `:aggregation` and `:expression`;; should get the arg removed if it's `nil` or empty. (For now. In the future we may change this if we make the;; 3-arg versions the "official" normalized versions.)@@ -219,7 +220,7 @@DEPRECATED: Use MBQL 5 + [[metabase.lib.core/update-options]] going forward."{:deprecated "0.57.0"}[clause & kvs]- (update-field-options clause #(apply assoc % kvs)))+ (apply update-field-options clause assoc kvs))(defn with-temporal-unit"Set the `:temporal-unit` of a `:field` clause to `unit`.diff --git a/src/metabase/lib/schema.cljc b/src/metabase/lib/schema.cljcindex 94e06704bd7..9f66a1ec5df 100644--- a/src/metabase/lib/schema.cljc+++ b/src/metabase/lib/schema.cljc@@ -570,98 +570,8 @@query)))(mr/def ::sandboxing.original-metadata- "The columns a query was expected to return *before* sandboxes replaced its source tables, stashed on the query by- the enterprise sandboxing middleware (see `expected-cols` in- `metabase-enterprise.sandbox.query-processor.middleware.sandboxing`) and compared against the sandboxed results- afterwards.-- In production these are legacy, `snake_cased` column metadata maps (i.e.- `:metabase.legacy-mbql.schema/legacy-column-metadata`), but some callers stash kebab-case, lib-flavored columns- here instead (see `metabase.lib.convert-test/round-trip-preserve-metadata-test`); this key is a verbatim snapshot- that must survive normalization untouched, so the elements mirror both key spellings without pointing at either- source schema, which would rewrite keys and drop deprecated ones on decode."- [:sequential- [:map {:closed true}- [:base_type {:optional true} [:maybe [:or :string :keyword]]]- [:base-type {:optional true} [:maybe [:or :string :keyword]]]- [:display_name {:optional true} [:maybe :string]]- [:display-name {:optional true} [:maybe :string]]- [:name {:optional true} [:maybe :string]]- [:active {:optional true} [:maybe :boolean]]- [:description {:optional true} [:maybe :string]]- [:binning_info {:optional true} [:maybe- [:map {:closed true}- [:strategy {:optional true} [:maybe [:or :string :keyword]]]- [:binning_strategy {:optional true} [:maybe [:or :string :keyword]]]- [:bin_width {:optional true} [:maybe number?]]- [:num_bins {:optional true} [:maybe :int]]- [:min_value {:optional true} [:maybe number?]]- [:max_value {:optional true} [:maybe number?]]]]]- [:coercion_strategy {:optional true} [:maybe [:or :string :keyword]]]- [:database_type {:optional true} [:maybe :string]]- [:effective_type {:optional true} [:maybe [:or :string :keyword]]]- [:effective-type {:optional true} [:maybe [:or :string :keyword]]]- [:converted_timezone {:optional true} [:maybe :string]]- [:field_ref {:optional true} [:maybe :metabase.legacy-mbql.schema/Reference]]- [:field-ref {:optional true} [:maybe :metabase.legacy-mbql.schema/Reference]]- [:fk_field_id {:optional true} [:maybe ::id/field]]- [:fk-field-id {:optional true} [:maybe ::id/field]]- [:fk_field_name {:optional true} [:maybe :string]]- [:fk_join_alias {:optional true} [:maybe :string]]- [:fk_target_field_id {:optional true} [:maybe ::id/field]]- [:fingerprint {:optional true} [:maybe :metabase.lib.schema.metadata.fingerprint/fingerprint]]- [:has_field_values {:optional true} [:maybe [:or :string :keyword]]]- [:id {:optional true} [:maybe ::id/field]]- [:inherited_temporal_unit {:optional true} [:maybe [:or :string :keyword]]]- [:nfc_path {:optional true} [:maybe [:sequential :string]]]- [:position {:optional true} [:maybe :int]]- [:custom_position {:optional true} [:maybe :int]]- [:database_position {:optional true} [:maybe :int]]- [:data_sensitivity {:optional true} [:maybe [:or :string :keyword]]]- [:fingerprint_version {:optional true} [:maybe :int]]- [:parent_id {:optional true} [:maybe ::id/field]]- [:points_of_interest {:optional true} [:maybe :string]]- [:preview_display {:optional true} [:maybe :boolean]]- [:caveats {:optional true} [:maybe :string]]- [:target {:optional true} [:maybe [:or ::id/field :metabase.legacy-mbql.schema/Reference]]]- [:options {:optional true} [:maybe :metabase.lib.schema.metadata/column.options]]- [:remapped_from {:optional true} [:maybe :string]]- [:remapped_to {:optional true} [:maybe :string]]- [:remapped_from_index {:optional true} [:maybe :int]]- [:source_alias {:optional true} [:maybe :string]]- [:aggregation_index {:optional true} [:maybe :int]]- [:expression_name {:optional true} [:maybe :string]]- [:special_type {:optional true} [:maybe [:or :string :keyword]]]- [:remapping {:optional true} [:maybe [:map-of [:ref :metabase.lib.schema.literal/literal]- [:ref :metabase.lib.schema.literal/literal]]]]- [:selected? {:optional true} [:maybe :boolean]]- [:semantic_type {:optional true} [:maybe [:or :string :keyword]]]- [:semantic-type {:optional true} [:maybe [:or :string :keyword]]]- [:settings {:optional true} [:maybe :metabase.lib.schema.common/visualization-settings]]- [:source {:optional true} [:maybe [:or :string :keyword]]]- [:table_id {:optional true} [:maybe ::id/table]]- [:table-id {:optional true} [:maybe ::id/table]]- [:unit {:optional true} [:maybe [:or :string :keyword]]]- [:visibility_type {:optional true} [:maybe [:or :string :keyword]]]- [:visibility-type {:optional true} [:maybe [:or :string :keyword]]]- [:lib/join-alias {:optional true} [:maybe :string]]- [:lib/source {:optional true} [:maybe [:ref ::lib.schema.metadata/column.source]]]- [:lib/breakout? {:optional true} [:maybe :boolean]]- [:lib/source-column-alias {:optional true} [:maybe :string]]- [:lib/desired-column-alias {:optional true} [:maybe :string]]- [:lib/original-name {:optional true} [:maybe :string]]- [:lib/deduplicated-name {:optional true} [:maybe :string]]- [:lib/original-display-name {:optional true} [:maybe :string]]- [:lib/simple-display-name {:optional true} [:maybe :string]]- [:lib/transformation-added-base-type {:optional true} [:maybe :boolean]]- [:database_partitioned {:optional true} [:maybe :boolean]]- [:lib/expression-name {:optional true} [:maybe :string]]- [:lib/external-remap {:optional true} [:maybe [:ref ::lib.schema.metadata/column.remapping.external]]]- [:lib/original-fk-field-id {:optional true} [:maybe ::id/field]]- [:lib/original-join-alias {:optional true} [:maybe :string]]- [:lib/card-id {:optional true} [:maybe ::id/card]]- [:lib/from-model? {:optional true} [:maybe :boolean]]- [:lib/temporal-unit {:optional true} [:maybe [:or :string :keyword]]]]])+ "The legacy columns a query was expected to return before sandboxes replaced its source tables, stashed on the query by the enterprise sandboxing middleware and merged into the sandboxed results."+ [:sequential [:ref :metabase.legacy-mbql.schema/legacy-column-metadata]])(mr/def ::query.snapshot"A whole copy of a query stashed on the query itself under one of the internal keys below: the same shape asdiff --git a/src/metabase/lib_be/schema.clj b/src/metabase/lib_be/schema.cljindex ed4a9990d19..50cd8431431 100644--- a/src/metabase/lib_be/schema.clj+++ b/src/metabase/lib_be/schema.clj@@ -56,6 +56,7 @@[:offset {:optional true} [:maybe :int]][:middleware {:optional true} [:ref ::lib.schema.middleware-options/middleware-options]][:info {:optional true} [:maybe [:ref ::lib.schema.info/info]]]+ [:viz-settings {:optional true} [:maybe ms/VisualizationSettings]][:action {:optional true} [:or :string :keyword]][:database {:optional true} [:maybe pos-int?]][:scope {:optional true} ::internal-query.scope]diff --git a/src/metabase/metabot/schema/v2.clj b/src/metabase/metabot/schema/v2.cljindex b2957c7e930..9150e0bbf5a 100644--- a/src/metabase/metabot/schema/v2.clj+++ b/src/metabase/metabot/schema/v2.clj@@ -91,77 +91,10 @@value, which JSON cannot represent.)"[:fn {:error/message "must be absent"} (fn [_] false)])-(mr/def ::tool-payload- "A metabot tool's `:structured-output`/`:structured_output`, `:resources`, or `:data-parts` data: a- closed bag of the field names metabot tools actually set."- [:map {:closed true}- [:result-type {:optional true} [:maybe [:or :string :keyword]]]- [:type {:optional true} [:maybe [:or :string :keyword]]]- [:list-type {:optional true} [:maybe [:or :string :keyword]]]- [:message {:optional true} [:maybe :string]]- [:path {:optional true} [:maybe :string]]- [:question {:optional true} [:maybe :string]]- [:options {:optional true} [:maybe [:sequential :string]]]- [:data {:optional true} [:maybe [:or [:ref ::tool-payload] [:sequential [:ref ::tool-payload]]]]]- [:total_count {:optional true} [:maybe :int]]- [:weak_match {:optional true} [:maybe :boolean]]- [:tables {:optional true} [:maybe [:sequential [:ref ::tool-payload]]]]- [:models {:optional true} [:maybe [:sequential [:ref ::tool-payload]]]]- [:metrics {:optional true} [:maybe [:sequential [:ref ::tool-payload]]]]- [:errors {:optional true} [:maybe [:sequential [:ref ::tool-payload]]]]- [:results {:optional true} [:maybe [:sequential [:ref ::tool-payload]]]]- [:id {:optional true} [:maybe [:or :int :string]]]- [:name {:optional true} [:maybe :string]]- [:description {:optional true} [:maybe :string]]- [:content {:optional true} [:maybe :string]]- [:document {:optional true} [:maybe :string]]- [:items {:optional true} [:maybe [:sequential [:ref ::tool-payload]]]]- [:total {:optional true} [:maybe :int]]- [:page {:optional true} [:maybe :int]]- [:pages {:optional true} [:maybe :int]]- [:card-id {:optional true} [:maybe :int]]- [:card_id {:optional true} [:maybe :int]]- [:collection-id {:optional true} [:maybe :int]]- [:collection_id {:optional true} [:maybe :int]]- [:destination {:optional true} [:maybe [:or :string [:ref ::tool-payload]]]]- [:todos {:optional true} [:maybe [:sequential :metabase.metabot.schema/todo]]]- [:todo_count {:optional true} [:maybe :int]]- [:events {:optional true} [:maybe [:sequential [:ref ::tool-payload]]]]- [:timestamp {:optional true} [:maybe :string]]- [:time_matters {:optional true} [:maybe :boolean]]- [:timezone {:optional true} [:maybe :string]]- [:status {:optional true} [:maybe :string]]- [:priority {:optional true} [:maybe :string]]- [:verified {:optional true} [:maybe :boolean]]- [:next-page-uri {:optional true} [:maybe :string]]- [:tabs {:optional true} [:maybe [:sequential [:ref ::tool-payload]]]]- [:approved {:optional true} [:maybe :boolean]]- [:success {:optional true} [:maybe :boolean]]- [:bad_transforms {:optional true} [:maybe [:sequential [:ref ::tool-payload]]]]- [:bad_questions {:optional true} [:maybe [:sequential [:ref ::tool-payload]]]]- [:query {:optional true} [:maybe :metabase.metabot.schema/query]]- [:query-id {:optional true} [:maybe :string]]- [:query_id {:optional true} [:maybe :string]]- [:query-content {:optional true} [:maybe :string]]- [:query-json {:optional true} [:maybe :string]]- [:result-columns {:optional true} [:maybe [:sequential :string]]]- [:database {:optional true} [:maybe :int]]- [:database_id {:optional true} [:maybe :int]]- [:sql_engine {:optional true} [:maybe :string]]- [:chart-type {:optional true} [:maybe [:or :string :keyword]]]- [:chart_type {:optional true} [:maybe [:or :string :keyword]]]- [:chart-id {:optional true} [:maybe :string]]- [:display {:optional true} [:maybe [:or :string :keyword]]]- [:tool {:optional true} [:maybe :string]]- [:dataset_query {:optional true} [:maybe :metabase.metabot.schema/query]]- [:transform {:optional true} [:maybe :metabase.metabot.schema/transform]]- [:target {:optional true} [:maybe [:ref ::tool-payload]]]- [:source {:optional true} [:maybe [:ref ::tool-payload]]]- [:schema {:optional true} [:maybe :string]]- [:url {:optional true} [:maybe :string]]- [:title {:optional true} [:maybe :string]]- [:entity_id {:optional true} [:maybe :int]]- [:link {:optional true} [:maybe :string]]])+(mr/def ::tool-io+ "A tool call's `:input`/`:rawInput`/`:output`: an arbitrary JSON value whose shape the calling tool (or the LLM+ provider) owns, not us."+ [:schema {::mr/deliberately-open true, :description "arbitrary tool call arguments or result"} :any])(mr/def ::structured-output"The `persisted-structured-output-keys` subset of a tool's `:structured-output`/@@ -174,10 +107,18 @@[:database {:optional true} [:maybe :int]][:chart-type {:optional true} [:maybe [:or :string :keyword]]]])+(mr/def ::migrated-v1-tool-output+ "A v1 row's raw tool result, which `metabase.metabot.schema.migrate-v1-to-v2/migrate-v1-native->v2` carries verbatim+ into a v2 tool part's `:output`, keyed by whatever the tool that returned it set."+ [:map {::mr/deliberately-open true, :description "a v1 row's raw tool result"}+ [:output {:optional true} ::tool-io]+ [:structured-output {:optional true} ::tool-io]+ [:structured_output {:optional true} ::tool-io]])+(mr/def ::stored-tool-output"A v2 tool part's `:output`: the trimmed value`metabase.metabot.persistence/tool-result->storable-output` stores, either a tool's bare- scalar result or the `:output`/`:structured_output` map trimmed from it."+ scalar result or the `:output`/`:structured_output` map trimmed from it, or a migrated v1 row's untrimmed result."[:or:string:keyword@@ -186,7 +127,8 @@:nil[:map {:closed true}[:output {:optional true} [:maybe :string]]- [:structured_output {:optional true} [:maybe ::structured-output]]]])+ [:structured_output {:optional true} [:maybe ::structured-output]]]+ ::migrated-v1-tool-output])(mr/def ::ui-message-chunk[:multi {:dispatch (fn [chunk]@@ -314,11 +256,6 @@[:type [:= "message-metadata"]][:messageMetadata {:optional true} :any]]]])-(mr/def ::tool-io- "A tool call's `:input`/`:rawInput`/`:output`: an arbitrary JSON value whose shape the calling tool (or the LLM- provider) owns, not us."- [:schema {::mr/deliberately-open true, :description "arbitrary tool call arguments or result"} :any])-(mr/def ::tool-ui-part[:multi {:dispatch :state}["input-streaming" [:map {:closed true}diff --git a/src/metabase/metabot/self/core.clj b/src/metabase/metabot/self/core.cljindex 97ffa73cabd..6a41bc53fe9 100644--- a/src/metabase/metabot/self/core.clj+++ b/src/metabase/metabot/self/core.clj@@ -9,7 +9,6 @@[malli.transform :as mtx][metabase.ai-tracing.core :as ait][metabase.llm.settings :as llm]- [metabase.metabot.schema :as metabot.schema][metabase.metabot.schema.v2 :as schema.v2][metabase.premium-features.core :as premium-features][metabase.request.schema :as request.schema]@@ -85,19 +84,13 @@[:capabilities {:optional true} [:maybe [:set :keyword]]][:scope {:optional true} [:maybe :string]]])-(def ^:private RawStructuredOutput- "A tool's own `:structured-output`/`:structured_output` map before- `metabase.metabot.persistence/tool-result->storable-output` trims it down to- `metabase.metabot.schema.v2/structured-output` for persistence."- [:or ::metabot.schema/transform ::schema.v2/tool-payload [:sequential ::schema.v2/tool-payload]])-(def ^:private DataPart"One entry of a tool's `:data-parts`: `metabase.metabot.agent.streaming`'s `{:type :data, ...}`constructors."[:map {:closed true}[:type [:= :data]][:data-type :string]- [:data {:optional true} [:maybe ::schema.v2/tool-payload]]])+ [:data {:optional true} [:maybe ::schema.v2/tool-io]]])(def ^:private ToolResult"The raw return value of a tool's `:fn`, before it is trimmed for persistence or forwarded to@@ -110,11 +103,11 @@:nil[:map {:closed true}[:output {:optional true} [:maybe :string]]- [:structured-output {:optional true} [:maybe RawStructuredOutput]]- [:structured_output {:optional true} [:maybe RawStructuredOutput]]+ [:structured-output {:optional true} [:maybe ::schema.v2/tool-io]]+ [:structured_output {:optional true} [:maybe ::schema.v2/tool-io]][:terminal-error? {:optional true} :boolean][:data-parts {:optional true} [:sequential DataPart]]- [:resources {:optional true} [:sequential ::schema.v2/tool-payload]]+ [:resources {:optional true} [:sequential ::schema.v2/tool-io]][:instructions {:optional true} [:maybe :string]][:status-code {:optional true} [:maybe :int]][:error {:optional true} [:maybe [:map {:closed true}@@ -138,8 +131,10 @@[:text {:optional true} [:maybe :string]][:content {:optional true} [:maybe :string]][:function {:optional true} [:maybe :string]]+ [:title {:optional true} [:maybe :string]][:arguments {:optional true} [:maybe ToolCallArguments]][:result {:optional true} [:maybe ToolResult]]+ [:duration-ms {:optional true} [:maybe number?]][:error {:optional true} [:maybe [:map {:closed true}[:message {:optional true} [:maybe :string]][:type {:optional true} [:maybe :string]]]]]@@ -152,6 +147,14 @@[:base-url {:optional true} [:maybe :string]][:model-reasoning {:optional true} [:maybe [:or :boolean :string]]]])+(def ^:private AzureCredentials+ "An Azure connection's config: the API-key pair plus the model family and deployment name its model is composed from."+ [:map {:closed true}+ [:api-key {:optional true} [:maybe :string]]+ [:base-url {:optional true} [:maybe :string]]+ [:model-family {:optional true} [:maybe :string]]+ [:deployment-name {:optional true} [:maybe :string]]])+(def ^:private BedrockCredentials[:map {:closed true}[:access-key-id {:optional true} [:maybe :string]]@@ -165,10 +168,11 @@[:oauth-access-token {:optional true} [:maybe :string]][:project-id {:optional true} [:maybe :string]][:location {:optional true} [:maybe :string]]+ [:auth-method {:optional true} [:maybe :string]][:base-url {:optional true} [:maybe :string]]])(def ^:private LLMCredentials- [:or ApiKeyCredentials BedrockCredentials GoogleCredentials])+ [:or ApiKeyCredentials AzureCredentials BedrockCredentials GoogleCredentials])(def ^:private ReasoningConfig"A dialect-shaped reasoning/thinking directive, sent verbatim to the provider."diff --git a/src/metabase/parameters/schema.cljc b/src/metabase/parameters/schema.cljcindex ec8ddd57594..959e1c15fa5 100644--- a/src/metabase/parameters/schema.cljc+++ b/src/metabase/parameters/schema.cljc@@ -172,6 +172,16 @@(mr/def ::api.parameter-values(json-encoded ::parameter-values)))+(mr/def ::parameter-with-stored-value+ "A parameter whose value is remembered for a user: the keys a client sends, or a Dashboard's stored declaration+ carrying the value the query ran with."+ [:or+ [:ref ::parameter-with-value]+ [:merge+ [:ref ::parameter]+ [:map {:closed true}+ [:value {:optional true} [:ref ::lib.schema.parameter/parameter.value]]]]])+(mr/def ::parameter-mapping"Schema for a valid Parameter Mapping"[:mapdiff --git a/src/metabase/plugins/initialize.clj b/src/metabase/plugins/initialize.cljindex f05cea99da2..8588419ca9d 100644--- a/src/metabase/plugins/initialize.clj+++ b/src/metabase/plugins/initialize.clj@@ -180,30 +180,35 @@(registered? plugin-name))(mr/def ::init-step- "One step under `init:` in a plugin manifest."+ "One step under `init:` in a plugin manifest, whose keys are the plugin author's."[:multi {:dispatch :step}- ["load-namespace" [:map {:closed true} [:step [:= "load-namespace"]] [:namespace :string]]]- ["register-jdbc-driver" [:map {:closed true} [:step [:= "register-jdbc-driver"]] [:class :string]]]])+ ["load-namespace" [:map {:closed false, ::mr/deliberately-open true, :description "plugin init step"}+ [:step [:= "load-namespace"]] [:namespace :string]]]+ ["register-jdbc-driver" [:map {:closed false, ::mr/deliberately-open true, :description "plugin init step"}+ [:step [:= "register-jdbc-driver"]] [:class :string]]]])(mr/def ::dependency- "One entry under `dependencies:` in a plugin manifest."+ "One entry under `dependencies:` in a plugin manifest, whose keys are the plugin author's."[:or- [:map {:closed true} [:class :string] [:message {:optional true} :string]]- [:map {:closed true} [:plugin :string]]- [:map {:closed true} [:env-var :string]]])+ [:map {:closed false, ::mr/deliberately-open true, :description "plugin class dependency"}+ [:class :string] [:message {:optional true} :string]]+ [:map {:closed false, ::mr/deliberately-open true, :description "plugin dependency on another plugin"}+ [:plugin :string]]+ [:map {:closed false, ::mr/deliberately-open true, :description "plugin env var dependency"}+ [:env-var :string]]])(mr/def ::connection-property- "One entry under `driver: connection-properties:` in a plugin manifest: a preset name, a full property map, a- `merge:` override list, or a `group:` of properties."+ "One entry under `driver: connection-properties:` in a plugin manifest, whose keys are the plugin author's: a preset+ name, a full property map, a `merge:` override list, or a `group:` of properties."[:or:string- [:map {:closed true}- [:group [:map {:closed true}+ [:map {:closed false, ::mr/deliberately-open true, :description "plugin connection property group"}+ [:group [:map {:closed false, ::mr/deliberately-open true, :description "plugin connection property group"}[:container-style {:optional true} [:sequential :string]][:fields [:sequential [:ref ::connection-property]]]]]]- [:map {:closed true}+ [:map {:closed false, ::mr/deliberately-open true, :description "plugin connection property merge"}[:merge [:sequential [:ref ::connection-property]]]]- [:map {:closed true}+ [:map {:closed false, ::mr/deliberately-open true, :description "plugin connection property"}[:name {:optional true} :string][:display-name {:optional true} :string][:helper-text {:optional true} :string]@@ -217,8 +222,8 @@[:visible-if {:optional true} [:map-of :string [:or :string :boolean [:sequential :string]]]]]])(mr/def ::driver-info- "The `driver:` section of a plugin manifest."- [:map {:closed true}+ "The `driver:` section of a plugin manifest, whose keys are the plugin author's."+ [:map {:closed false, ::mr/deliberately-open true, :description "plugin driver info"}[:name :string][:display-name {:optional true} :string][:lazy-load {:optional true} :boolean]@@ -228,18 +233,27 @@[:connection-properties-include-tunnel-config {:optional true} :boolean]])(mr/def ::extra-info- "The `extra:` section of a plugin manifest."- [:map {:closed true}- [:db-routing-info {:optional true} [:map {:closed true} [:text :string]]]])+ "The `extra:` section of a plugin manifest, whose keys are the plugin author's."+ [:map {:closed false, ::mr/deliberately-open true, :description "plugin extra info"}+ [:db-routing-info {:optional true} [:map {:closed false, ::mr/deliberately-open true, :description "plugin db routing info"}+ [:text :string]]]])++(mr/def ::contact-info+ "The `contact-info:` section of a plugin manifest, whose keys are the plugin author's."+ [:map {:closed false, ::mr/deliberately-open true, :description "plugin contact info"}+ [:name {:optional true} :string]+ [:address {:optional true} :string]])(mr/def ::manifest- "A parsed `metabase-plugin.yaml` manifest, as handed to [[register-plugin-with-info!]]."- [:map {:closed true}+ "A parsed `metabase-plugin.yaml` manifest as handed to [[register-plugin-with-info!]], whose keys are the plugin+ author's."+ [:map {:closed false, ::mr/deliberately-open true, :description "plugin manifest"}[:metabase-plugin-api-version {:optional true} :int]- [:info [:map {:closed true}+ [:info [:map {:closed false, ::mr/deliberately-open true, :description "plugin info"}[:name :string][:version :string][:description {:optional true} :string]]]+ [:contact-info {:optional true} ::contact-info][:driver {:optional true} [:maybe [:or ::driver-info [:sequential ::driver-info]]]][:init {:optional true} [:sequential ::init-step]][:dependencies {:optional true} [:sequential ::dependency]]diff --git a/src/metabase/premium_features/token_check.clj b/src/metabase/premium_features/token_check.cljindex b20b554ac21..7393b1434ff 100644--- a/src/metabase/premium_features/token_check.clj+++ b/src/metabase/premium_features/token_check.clj@@ -163,9 +163,21 @@also being the license server's."[:map {:closed false, ::mr/deliberately-open true, :description "license-server meters"}])+(def ^:private StoreUser+ "A store user of a token status response, whose keys are the license server's."+ [:map {:closed false, ::mr/deliberately-open true, :description "license-server store user"}+ [:email :string]])++(def ^:private Quota+ "A quota of a token status response, whose keys are the license server's."+ [:map {:closed false, ::mr/deliberately-open true, :description "license-server quota"}+ [:hosting-feature {:optional true} :string]+ [:soft-limit {:optional true} number?]+ [:usage {:optional true} number?]])+(def TokenStatus- "Schema for a response from the token status API."- [:map {:closed true}+ "Schema for a response from the token status API, whose keys are the license server's."+ [:map {:closed false, ::mr/deliberately-open true, :description "license-server token status"}[:valid :boolean][:status [:string {:min 1}]][:error-details {:optional true} [:maybe [:string {:min 1}]]]@@ -176,13 +188,9 @@[:valid-thru {:optional true} [:string {:min 1}]][:max-users {:optional true} pos-int?][:company {:optional true} [:string {:min 1}]]- [:store-users {:optional true} [:maybe [:sequential [:map {:closed true}- [:email :string]]]]]+ [:store-users {:optional true} [:maybe [:sequential StoreUser]]][:meters {:optional true} Meters]- [:quotas {:optional true} [:sequential [:map {:closed true}- [:hosting-feature {:optional true} :string]- [:soft-limit {:optional true} number?]- [:usage {:optional true} number?]]]]])+ [:quotas {:optional true} [:sequential Quota]]])(defn- http-fetch[base-url token site-uuid]diff --git a/src/metabase/pulse/models/pulse.clj b/src/metabase/pulse/models/pulse.cljindex 448bb350d92..ede5385f51d 100644--- a/src/metabase/pulse/models/pulse.clj+++ b/src/metabase/pulse/models/pulse.clj@@ -246,9 +246,8 @@"dashboard_id" "parameter_mappings"]))))(def CoercibleToCardRef- "Schema for functions accepting either a `HybridPulseCard`, `CardRef`, `CardBase`, or a full Card row- (as `card->ref` accepts \"a card or id\")."- [:or HybridPulseCard CardRef CardBase :metabase.queries.schema/card])+ "Schema for functions accepting either a `HybridPulseCard`, `CardRef`, or `CardBase`."+ [:or HybridPulseCard CardRef CardBase])(def ^:private RecipientInput"One entry of `PulseChannelInput`'s `:recipients`: either a Metabase User (by `:id`) or a raw email address."@@ -544,7 +543,7 @@(mu/defn card->ref :- CardRef"Create a card reference from a card or id"- [card :- CoercibleToCardRef]+ [card :- [:or CoercibleToCardRef :metabase.queries.schema/card]]{:id (u/the-id card):include_csv (get card :include_csv false):include_xls (get card :include_xls false)diff --git a/src/metabase/queries/models/card/metadata.clj b/src/metabase/queries/models/card/metadata.cljindex 098e5173890..e3e39cf3407 100644--- a/src/metabase/queries/models/card/metadata.clj+++ b/src/metabase/queries/models/card/metadata.clj@@ -7,7 +7,6 @@[metabase.lib-be.core :as lib-be][metabase.lib-be.schema :as lib-be.schema][metabase.lib.core :as lib]- [metabase.lib.schema.id :as lib.schema.id][metabase.lib.schema.metadata :as lib.schema.metadata][metabase.models.interface :as mi][metabase.queries.db :as queries.db]@@ -163,9 +162,7 @@ saved later when it is ready.""Save metadata when (and if) it is ready. Takes a chan that will eventually return metadata. Waits upto [[metadata-async-timeout-ms]] for the metadata, and then saves it if the query of the card has not changed."[result-metadata-future :- ::future- card :- [:map {:closed true}- [:id ::lib.schema.id/card]- [:dataset_query ::lib-be.schema/maybe-legacy-or-empty-query]]]+ card :- ::queries.schema/card](let [id (u/the-id card)](future(trydiff --git a/src/metabase/query_processor/card.clj b/src/metabase/query_processor/card.cljindex 90ebdc0a3ff..4bb5e36f8d6 100644--- a/src/metabase/query_processor/card.clj+++ b/src/metabase/query_processor/card.clj@@ -430,7 +430,6 @@(or qp process-query-for-card-default-qp))runner (make-run qp export-format)query (-> (query-for-card card parameters constraints middleware {:dashboard-id dashboard-id})- api/check-404(assoc :viz-settings merged-viz)(update :middleware (fn [middleware](mergediff --git a/src/metabase/security_center/schema.clj b/src/metabase/security_center/schema.cljindex c06353e82fe..2085fe6aa56 100644--- a/src/metabase/security_center/schema.clj+++ b/src/metabase/security_center/schema.clj@@ -18,8 +18,8 @@[:enum :unknown :active :resolved :not_affected :error])(mr/def ::version-range- "A single affected version range with inclusive min and exclusive fixed."- [:map {:closed true}+ "A single affected version range with inclusive min and exclusive fixed, whose keys are the MetaStore's."+ [:map {:closed false, ::mr/deliberately-open true, :description "MetaStore affected version range"}[:min ::semver][:fixed ::semver]])@@ -27,8 +27,8 @@[:sequential ::version-range])(mr/def ::download-jar-url- "A downloadable JAR for a given fixed version."- [:map {:closed true}+ "A downloadable JAR for a given fixed version, whose keys are the MetaStore's."+ [:map {:closed false, ::mr/deliberately-open true, :description "MetaStore downloadable JAR"}[:version ::semver][:url :string]])diff --git a/src/metabase/transforms/models/transform.clj b/src/metabase/transforms/models/transform.cljindex 1c5197e0f9f..04cc0e2d6ed 100644--- a/src/metabase/transforms/models/transform.clj+++ b/src/metabase/transforms/models/transform.clj@@ -283,7 +283,7 @@last-runs (m/index-by :transform_id (transform-run/latest-runs transform-ids))](for [{transform-id :id :as transform} transforms](let [{:keys [status checkpoint_hi_value] :as last-run} (get last-runs transform-id)- transform (assoc transform :last_run last-run)]+ transform (assoc transform :last_run (dissoc last-run :last_heartbeat))](if (and (= status :succeeded) checkpoint_hi_value);; ensure consistency of last_checkpoint_value with last_run(if (:last_checkpoint_value transform)@@ -484,7 +484,7 @@;; the importer skips ref resolution.(-> source(assoc :serdes/unresolved true)- (m/update-existing :query assoc :database nil)+ (m/update-existing :query #(-> % (dissoc :lib/metadata) (assoc :database nil)))(m/update-existing :source-database (constantly nil))(m/update-existing :source-tables#(mapv (fn [e] (assoc e :table_id nil :database_id nil)) %))@@ -492,7 +492,9 @@:import(fn [source](if (:serdes/unresolved source)- (dissoc source :serdes/unresolved)+ (-> source+ (dissoc :serdes/unresolved)+ (m/update-existing :query dissoc :lib/metadata))(-> source(m/update-existing :query serdes/import-mbql)(m/update-existing :source-database import-maybe-int-database-fk)diff --git a/src/metabase/users/models/user_parameter_value.clj b/src/metabase/users/models/user_parameter_value.cljindex 2ff95271b01..61e61fbc707 100644--- a/src/metabase/users/models/user_parameter_value.clj+++ b/src/metabase/users/models/user_parameter_value.clj@@ -70,7 +70,7 @@"Asynchronously delete params with a nil `value` and upsert the rest."[user-id :- pos-int?dashboard-id :- pos-int?- parameters :- [:sequential :metabase.parameters.schema/parameter-with-value]]+ parameters :- [:sequential :metabase.parameters.schema/parameter-with-stored-value]](when (setting/get :dashboards-save-last-used-parameters)(grouper/submit! @user-parameter-value-queue {:user-id user-id:dashboard-id dashboard-iddiff --git a/test/metabase/channel/slack_test.clj b/test/metabase/channel/slack_test.cljindex e82367bce10..298b7bc3c2d 100644--- a/test/metabase/channel/slack_test.clj+++ b/test/metabase/channel/slack_test.clj@@ -4,6 +4,9 @@[clojure.set :as s][clojure.test :refer :all][medley.core :as m]+ [metabase.channel.api.slack :as channel.api.slack]+ [metabase.channel.impl.slack :as channel.impl.slack]+ [metabase.channel.render.core :as channel.render][metabase.channel.settings :as channel.settings][metabase.channel.slack :as slack][metabase.notification.test-util :as notification.tu]@@ -303,6 +306,29 @@(is (=? expected(slack/post-chat-message! {:channel "C94712B6X" :text ":wow:"}))))))))+(deftest post-chat-message!-built-blocks-test+ (testing "post-chat-message! accepts the blocks Metabase builds for card notifications and bug reports"+ (let [card-blocks (mt/with-dynamic-fn-redefs [channel.render/render-pulse-card (fn [& _] {:attachments {}, :content [:div]})+ channel.render/png-from-render-info (fn [& _] (byte-array [1]))+ slack/upload-file! (fn [_ _] {:id "F0CARD"})]+ (mt/with-temporary-setting-values [site-url "a.com"]+ (#'channel.impl.slack/part->sections! {:type :card, :card {:id 1, :name "Card"}})))+ bug-blocks (#'channel.api.slack/create-slack-message-blocks+ {:url "https://test.com", :description "Broken", :bugReportDetails {}}+ {:id "F0BUG", :url "https://files.slack.com/files-pri/123/diagnostic.json"})]+ (is (=? [{:text {:verbatim true}} {:slack_file {:id "F0CARD"}}] card-blocks))+ (is (=? [{:elements [{:elements [{} {} {:style {:bold true}}]}]}+ {}+ {:elements [{} {:border 0}]}+ {}+ {:elements [{:url string?, :style "primary"} {}]}]+ bug-blocks))+ (http-fake/with-fake-routes {#"^https://slack.com/api/chat\.postMessage.*"+ (fn [_] (mock-200-response (slurp "./test_resources/slack_post_chat_message_response.json")))}+ (mt/with-temporary-setting-values [slack-app-token "test-token"]+ (is (=? {:ok true}+ (slack/post-chat-message! {:channel "C94712B6X", :blocks (into card-blocks bug-blocks)}))))))))+(deftest slack-token-error-test(notification.tu/with-send-notification-sync(mt/with-temporary-setting-values [slack-app-token "test-token"diff --git a/test/metabase/embedding_rest/api/embed_test.clj b/test/metabase/embedding_rest/api/embed_test.cljindex 78142b2f30e..fcc34fc272e 100644--- a/test/metabase/embedding_rest/api/embed_test.clj+++ b/test/metabase/embedding_rest/api/embed_test.clj@@ -1875,6 +1875,36 @@(is (= [3443](mt/first-row (client/client :get 202 (card-query-url card "" {:params {:qty_locked 1}}))))))))))+(deftest numeric-parameters-json-query-param-test+ (testing "Card and dashcard query endpoints accept numeric values in the `parameters` JSON query param"+ (mt/dataset test-data+ (with-embedding-enabled-and-new-secret-key!+ (mt/with-temp [:model/Card {card-id :id, :as card} {:dataset_query (-> (lib/native-query (mt/metadata-provider)+ "SELECT count(*) FROM orders WHERE quantity = {{qty}}")+ (lib/with-template-tags+ {"qty" {:id "_qty_tag_"+ :name "qty"+ :display-name "Quantity"+ :type :number}}))+ :enable_embedding true+ :embedding_params {:qty "enabled"}}+ :model/Dashboard dashboard {:enable_embedding true+ :embedding_params {:qty "enabled"}+ :parameters [{:id "_qty_" :slug "qty" :name "Quantity" :type :number/=}]}+ :model/DashboardCard dashcard {:dashboard_id (u/the-id dashboard)+ :card_id card-id+ :parameter_mappings [{:parameter_id "_qty_"+ :card_id card-id+ :target [:variable [:template-tag "qty"]]}]}]+ (let [expected (mt/rows (client/client :get 202 (card-query-url card "") :qty "1"))]+ (is (pos? (ffirst expected)))+ (testing "Card"+ (is (= expected+ (mt/rows (client/client :get 202 (card-query-url card "") :parameters (json/encode {:qty 1}))))))+ (testing "Dashcard"+ (is (= expected+ (mt/rows (client/client :get 202 (dashcard-url dashcard) :parameters (json/encode {:qty 1}))))))))))))+(deftest biginteger-numeric-param-between-test(testing "Embedded numeric params with mixed long and biginteger values in a between filter should be correctly applied"(mt/dataset test-datadiff --git a/test/metabase/legacy_mbql/normalize_test.cljc b/test/metabase/legacy_mbql/normalize_test.cljcindex 29493ee8a07..220171779f1 100644--- a/test/metabase/legacy_mbql/normalize_test.cljc+++ b/test/metabase/legacy_mbql/normalize_test.cljc@@ -79,9 +79,9 @@(deftest ^:parallel normalize-test-8(testing ":value clauses should keep snake_case keys in the options (#23354)"- (let [clause [:value "some value" {:some_key "some key value"}]]+ (let [clause [:value "some value" {:database_type "some key value"}]](is (= clause- (mbql.normalize/normalize ::mbql.s/value [:value "some value" {:some_key "some key value"}]))))))+ (mbql.normalize/normalize ::mbql.s/value [:value "some value" {:database_type "some key value"}]))))))(deftest ^:parallel normalize-test-9(testing ":value clauses should keep snake_case keys in the type info args (#23354)"@@ -1632,6 +1632,9 @@(deftest ^:parallel normalize-datetime-test(is (= [:datetime ""](mbql.normalize/normalize [:datetime ""])))+ (testing "if we add other options, they are dropped (and don't break anything)"+ (is (= [:datetime "" {:mode :iso}]+ (mbql.normalize/normalize [:datetime "" {"x" "x", "mode" "iso"}]))))(is (= [:datetime "" {:mode :iso}](mbql.normalize/normalize [:datetime "" {:mode :iso}])(mbql.normalize/normalize [:datetime "" {:mode "iso"}])@@ -1684,6 +1687,33 @@nil]]{"default" ["field" 5 {}]}]))))+(deftest ^:parallel normalize-undeclared-clause-options-test+ (testing "Undeclared keys in clause options are dropped instead of leaving the clause and its parents un-normalized, and keys MBQL 5 options allow are kept"+ (is (= {:database 1+ :type :query+ :query {:source-table 2+ :expressions {"c" [:case [[[:> [:field 3 nil] 0] [:field 3 nil]]] {:default [:field 5 nil]}]+ "d" [:datetime [:field 6 nil] {:mode :iso}]}+ :aggregation [[:aggregation-options [:count] {:display-name "C"}]]+ :filter [:and+ [:contains [:field 1 nil] "x" {:case-sensitive false, :display-name "f"}]+ [:time-interval [:field 4 nil] :current :day {:include-current true}]+ [:= [:field 1 nil] [:value "x" {:base_type :type/Text}]]+ [:between [:field 2 nil] 1 10]]}}+ (mbql.normalize/normalize+ {"database" 1+ "type" "query"+ "query" {"source-table" 2+ "expressions" {"c" ["case" [[[">" ["field" 3 nil] 0] ["field" 3 nil]]]+ {"default" ["field" 5 nil], "x" 1}]+ "d" ["datetime" ["field" 6 nil] {"mode" "iso", "x" 1}]}+ "aggregation" [["aggregation-options" ["count"] {"display-name" "C", "x" 1}]]+ "filter" ["and"+ ["contains" ["field" 1 nil] "x" {"case-sensitive" false, "display-name" "f", "x" 1}]+ ["time-interval" ["field" 4 nil] "current" "day" {"include-current" true, "x" 1}]+ ["=" ["field" 1 nil] ["value" "x" {"base_type" "type/Text", "x" 1}]]+ ["between" ["field" 2 nil] 1 10]]}})))))+(deftest ^:parallel normalize-literal-strings-in-custom-aggregations-test(testing "Strings are allowed as arguments to a custom aggregation (#66199)"(is (= [:max "Literal String"]diff --git a/test/metabase/legacy_mbql/util_test.cljc b/test/metabase/legacy_mbql/util_test.cljcindex eadf25f2e38..8f2adabe1aa 100644--- a/test/metabase/legacy_mbql/util_test.cljc+++ b/test/metabase/legacy_mbql/util_test.cljc@@ -128,6 +128,15 @@(mbql.u/update-field-options [:field 1 {:display-name "Meh"}] #(assoc % :display-name "Wow"))))(t/is (= [:field 1 {:name "a", :display-name "b"}](mbql.u/update-field-options [:field 1 {:name "a"}] #(assoc % :display-name "b"))))+ (t/testing "Should pass extra args to `f`, like `clojure.core/update`"+ (t/is (= [:field 1 {:name "a", :display-name "b"}]+ (mbql.u/update-field-options [:field 1 {:name "a"}] assoc :display-name "b")))+ (t/is (= [:field 1 {:binning {:strategy :num-bins, :num-bins 10}}]+ (mbql.u/update-field-options [:field 1 nil] assoc-in [:binning] {:strategy :num-bins, :num-bins 10})))+ (t/is (= [:field 1 {:binning {:strategy :num-bins, :num-bins 20}}]+ (mbql.u/update-field-options [:field 1 {:binning {:strategy :num-bins, :num-bins 10}}] update-in [:binning :num-bins] * 2)))+ (t/is (= [:expression "wow"]+ (mbql.u/update-field-options [:expression "wow" {:display-name "b", :name "a"}] dissoc :display-name :name))))(t/testing "Should remove empty options"(t/is (= [:field 1 nil](mbql.u/update-field-options [:field 1 {:name "a"}] #(dissoc % :name)))))diff --git a/test/metabase/lib/convert_test.cljc b/test/metabase/lib/convert_test.cljcindex 57ef6a0b6bf..c7a569127c5 100644--- a/test/metabase/lib/convert_test.cljc+++ b/test/metabase/lib/convert_test.cljc@@ -839,18 +839,18 @@:base_type :type/Integer}]}:metabase-enterprise.sandbox.query-processor.middleware.sandboxing/original-metadata- [{:base-type :type/Text- :semantic-type :type/Category- :table-id 32600+ [{:base_type :type/Text+ :semantic_type :type/Category+ :table_id 32600:name "category":source :breakout- :effective-type :type/Text+ :effective_type :type/Text:id 134551- :lib/join-alias "products__via__product_id"- :visibility-type :normal- :display-name "Product → Category"- :field-ref [:field 134551 {:source-field 134534}]- :fk-field-id 134534+ :lib/join-alias "products__via__product_id"+ :visibility_type :normal+ :display_name "Product → Category"+ :field_ref [:field 134551 {:source-field 134534}]+ :fk_field_id 134534:fingerprint {:global {:distinct-count 4, :nil% 0.0}:type {:type/Text {:percent-json 0.0:percent-url 0.0diff --git a/test/metabase/metabot/agent/core_test.clj b/test/metabase/metabot/agent/core_test.cljindex 98176bea0dd..9849d0d2ba2 100644--- a/test/metabase/metabot/agent/core_test.clj+++ b/test/metabase/metabot/agent/core_test.clj@@ -1,5 +1,6 @@(ns metabase.metabot.agent.core-test(:require+ [clj-http.client :as http][clojure.string :as str][clojure.test :refer :all][metabase.ai-tracing.core :as ait]@@ -15,12 +16,14 @@[metabase.metabot.agent.profiles :as profiles][metabase.metabot.persistence :as metabot.persistence][metabase.metabot.self :as self]+ [metabase.metabot.self.core :as self.core][metabase.metabot.self.openrouter :as openrouter][metabase.metabot.test-util :as mut][metabase.metabot.tools.search :as metabot-search][metabase.permissions.core :as perms][metabase.permissions.models.permissions-group :as perms-group][metabase.test :as mt]+ [metabase.util.json :as json][toucan2.core :as t2]))(set! *warn-on-reflection* true)@@ -643,6 +646,67 @@(is (= 3 @llm-call-count)"Should have exactly 3 LLM calls (search, construct, final text)")))))))))+(defn- chat-completions-chunks+ "Raw Chat Completions stream chunks for one assistant turn: a tool call when `tool-call` is given, text otherwise."+ [message-id {:keys [tool-call text]}]+ [{:id message-id+ :model "anthropic/claude-haiku-4-5"+ :choices [{:index 0+ :delta (if tool-call+ {:tool_calls [{:index 0+ :id (:id tool-call)+ :type "function"+ :function {:name (:name tool-call)+ :arguments (json/encode (:arguments tool-call))}}]}+ {:content text})}]}+ {:id message-id+ :choices [{:index 0 :delta {} :finish_reason (if tool-call "tool_calls" "stop")}]}])++(deftest replayed-tool-history-reaches-the-provider-adapter-test+ (testing "a tool call's replayed parts, with their tool-owned result payloads, pass the adapter's request schema"+ (mt/as-admin+ (mt/with-temporary-setting-values [llm-providers llm.tu/default-connections+ llm-metabot-provider test-provider]+ (let [requests (atom [])+ responses [(chat-completions-chunks "chatcmpl-1"+ {:tool-call {:id "call-search-1"+ :name "search"+ :arguments {:semantic_queries ["orders table"]+ :keyword_queries ["orders"]+ :entity_types ["table"]}}})+ (chat-completions-chunks "chatcmpl-2" {:text "The orders table has what you need."})]]+ (mt/with-dynamic-fn-redefs [self.core/sse-reducible identity+ http/request (fn [req]+ (let [n (count (swap! requests conj req))]+ {:status 200 :body (get responses (dec n) [])}))+ metabot-search/search (fn [_args]+ [{:id (mt/id :orders)+ :type "table"+ :name "ORDERS"+ :display_name "Orders"+ :description "Confirmed orders."+ :database_id (mt/id)+ :database_schema "PUBLIC"+ :moderated_status nil+ :collection {:id nil :name nil}}])]+ (let [result (mt/with-log-level [metabase.metabot.agent.core :fatal]+ (into [] (agent/run-agent-loop+ {:messages [{:role :user :content "Where are the orders?"}]+ :state {}+ :profile-id :internal+ :context {}})))+ replay-body (some-> (second @requests) :body json/decode+kw)]+ (is (= [] (filterv #(= :error (:type %)) result)))+ (is (=? {:type :tool-output :function "search" :duration-ms number?}+ (first (filter #(= :tool-output (:type %)) result))))+ (is (= 2 (count @requests)))+ (is (=? [{:role "assistant"+ :tool_calls [{:id "call-search-1" :function {:name "search"}}]}+ {:role "tool" :tool_call_id "call-search-1" :content string?}]+ (filterv #(or (:tool_calls %) (= "tool" (:role %))) (:messages replay-body))))+ (is (=? {:type :text :text "The orders table has what you need."}+ (last (filter #(= :text (:type %)) result)))))))))))+(deftest eval-tracing-nesting-test(testing "capture-reducible over the real agent loop builds a turn -> llm -> tool span tree";; This exercises the cross-module wiring the ai-tracing docstrings promise: the turn/llm spansdiff --git a/test/metabase/metabot/models/metabot_message_test.clj b/test/metabase/metabot/models/metabot_message_test.cljindex 1a41cac51f2..8b55c4d1491 100644--- a/test/metabase/metabot/models/metabot_message_test.clj+++ b/test/metabase/metabot/models/metabot_message_test.clj@@ -21,6 +21,35 @@:from [:metabot_message]:where [:= :id (:id msg)]}))))))))+(deftest after-select-migrates-v1-tool-results-test+ (let [result {:output "Created query q1."+ :structured-output {:result-type "query"+ :query-id "q1"+ :query-content "SELECT * FROM ORDERS"+ :database 1+ :result-columns ["ID" "TOTAL"]}+ :data-parts [{:type "data" :data-type "navigate_to" :data "/question#abc"}]+ :resources [{:uri "metabase://table/1" :content "<table/>"}]}]+ (mt/with-temp [:model/MetabotConversation conv {}+ :model/MetabotMessage msg {:conversation_id (:id conv)+ :role "assistant"+ :data [{:type "tool-input" :id "tc1" :function "create_sql_query"+ :arguments {:sql "SELECT * FROM ORDERS"}}+ {:type "tool-output" :id "tc1" :function "create_sql_query"+ :result result :error nil :duration-ms 12}+ {:type "text" :id "t1" :text "Here it is."}]+ :data_version 1}]+ (let [row (t2/select-one :model/MetabotMessage :id (:id msg))]+ (testing "a v1 native tool result migrates on read, carried verbatim as the v2 tool part's output"+ (is (= [{:type "tool-create_sql_query"+ :toolCallId "tc1"+ :state "output-available"+ :input {:sql "SELECT * FROM ORDERS"}+ :output result}+ {:type "text" :text "Here it is."}]+ (:data row)))+ (is (= 2 (:data_version row))))))))+(deftest after-select-passes-v2-data-through-test(mt/with-temp [:model/MetabotConversation conv {}:model/MetabotMessage msg {:conversation_id (:id conv)diff --git a/test/metabase/metabot/self_test.clj b/test/metabase/metabot/self_test.cljindex f9ec4abfb2c..9c58b0a8943 100644--- a/test/metabase/metabot/self_test.clj+++ b/test/metabase/metabot/self_test.clj@@ -161,6 +161,22 @@(is (= (when fast? "fast-mode-2026-02-01")(get-in @captured [:headers "anthropic-beta"]))))))))))))+(deftest call-llm-serves-azure-and-google-connections-test+ (testing "the Azure and Google adapters accept their connection's resolved config, registry defaults included"+ (llm.tu/with-default-connections+ (doseq [[model-ref url-part] [["azure/openai/gpt-4.1-mini" "/v1/responses"]+ ["azure/anthropic/claude-deployment" "/v1/messages"]+ ["google/google/gemini-3.5-flash" "projects/my-project/locations/global"]+ ["google/anthropic/claude-haiku-4-5@20251001" "/publishers/anthropic/models/claude-haiku-4-5@20251001"]]]+ (testing model-ref+ (let [captured (atom nil)]+ (mt/with-dynamic-fn-redefs [self.core/sse-reducible identity+ http/request (fn [req]+ (reset! captured req)+ {:status 200 :body []})]+ (run! identity (self/call-llm model-ref nil [{:role :user :content "hi"}] {} {:tag "agent"}))+ (is (str/includes? (str (:url @captured)) url-part)))))))))+(deftest request-timeout-settings-test(testing "request seeds timeouts from the llm-*-timeout-ms settings, read at call time"(let [captured (atom nil)]diff --git a/test/metabase/notification/payload/execute_test.clj b/test/metabase/notification/payload/execute_test.cljindex 2e5a8791e69..87d9073265c 100644--- a/test/metabase/notification/payload/execute_test.clj+++ b/test/metabase/notification/payload/execute_test.clj@@ -2,9 +2,13 @@{:clj-kondo/config '{:linters {:deprecated-var {:exclude {metabase.test.data/mbql-query {:namespaces [metabase.notification.payload.execute-test]}}}}}}(:require[clojure.test :refer :all]+ [metabase.lib.core :as lib]+ [metabase.lib.metadata :as lib.metadata][metabase.notification.payload.execute :as notification.payload.execute][metabase.notification.payload.temp-storage :as temp-storage]- [metabase.test :as mt]))+ [metabase.query-processor.test :as qp]+ [metabase.test :as mt]+ [toucan2.core :as t2]))(set! *warn-on-reflection* true)@@ -113,3 +117,38 @@"with a shared budget the cumulative cells across tabs cross the cap, so a later card spills to disk");; clean up any temp files we created(doseq [p parts] (temp-storage/cleanup! (-> p :result :data :rows)))))))++(deftest execute-dashboard-with-stored-parameter-declarations-test+ (testing "subscription cards run with the dashboard's full stored parameter declarations and save their last used values"+ (mt/test-helpers-set-global-values!+ (mt/with-temporary-setting-values [synchronous-batch-updates true+ dashboards-save-last-used-parameters true]+ (let [mp (mt/metadata-provider)+ price (lib.metadata/field mp (mt/id :venues :price))+ query (-> (lib/query mp (lib.metadata/table mp (mt/id :venues)))+ (lib/aggregate (lib/count)))+ parameter {:id "_PRICE_"+ :name "Price"+ :slug "price"+ :type :number/=+ :sectionId "number"+ :required false+ :isMultiSelect true+ :values_query_type :list+ :value [4]}]+ (mt/with-temp [:model/Card {card-id :id} {:dataset_query query}+ :model/Dashboard {dash-id :id} {:parameters [(dissoc parameter :value)]}+ :model/DashboardCard _ {:dashboard_id dash-id+ :card_id card-id+ :parameter_mappings [{:parameter_id "_PRICE_"+ :card_id card-id+ :target [:dimension (lib/->legacy-MBQL (lib/ref price))]}]}]+ (let [part (first (card-parts (notification.payload.execute/execute-dashboard+ dash-id (mt/user->id :rasta) [parameter])))]+ (is (= (mt/rows (qp/process-query (lib/filter query (lib/= price 4))))+ (-> part :result :data :rows)))+ (is (= [4]+ (t2/select-one-fn :value :model/UserParameterValue+ :user_id (mt/user->id :rasta)+ :dashboard_id dash-id+ :parameter_id "_PRICE_"))))))))))diff --git a/test/metabase/plugins/initialize_test.clj b/test/metabase/plugins/initialize_test.cljindex edbf44e100e..0d228709803 100644--- a/test/metabase/plugins/initialize_test.clj+++ b/test/metabase/plugins/initialize_test.clj@@ -7,7 +7,8 @@[metabase.plugins.init-steps :as init-steps][metabase.plugins.initialize :as initialize][metabase.plugins.lazy-loaded-driver :as lazy-loaded-driver]- [metabase.test :as mt]))+ [metabase.test :as mt]+ [metabase.util.yaml :as yaml]))(set! *warn-on-reflection* true)@@ -90,6 +91,44 @@(is (= [:classpath [:init (:init plugin)]] @calls)"the driver placeholder uses the shared idempotent plugin loader")))+(deftest docs-shaped-driver-manifest-registers-test+ (testing "a manifest with `contact-info:`, a `select` property's `options:`, and keys we don't know registers its driver"+ (let [driver-name (str "test-docs-driver-" (random-uuid))+ manifest (initialize/normalize-manifest+ (yaml/parse-string+ (str "info:\n"+ " name: Test Docs Driver " driver-name "\n"+ " version: 1.0.0\n"+ " author-url: https://example.com\n"+ "contact-info:\n"+ " name: Toucan McBird\n"+ " address: [email protected]\n"+ "driver:\n"+ " name: " driver-name "\n"+ " display-name: Test Docs\n"+ " lazy-load: true\n"+ " abstract: true\n"+ " connection-properties:\n"+ " - host\n"+ " - name: mode\n"+ " display-name: Mode\n"+ " type: select\n"+ " options:\n"+ " - name: Fast\n"+ " value: fast\n"+ " - name: Safe\n"+ " value: safe\n"+ "init:\n"+ " - step: load-namespace\n"+ " namespace: example.driver\n")))]+ (mt/with-dynamic-fn-redefs [deps/all-dependencies-satisfied? (constantly true)+ deps/update-unsatisfied-deps! (constantly [])]+ (is (= :ok (initialize/register-plugin-with-info! (assoc manifest :add-to-classpath! (constantly nil)))))+ (is (= {:name "Toucan McBird", :address "[email protected]"}+ (driver/contact-info (keyword driver-name))))+ (is (=? [{:name "mode", :options [{:name "Fast", :value "fast"} {:name "Safe", :value "safe"}]}]+ (filter #(= "mode" (:name %)) (driver/connection-properties (keyword driver-name)))))))))+(deftest driver-plugin-can-opt-out-of-lazy-loading-test(let [calls (atom [])plugin {:info {:name (str "test eager driver plugin " (random-uuid)) :version "1.0.0"}diff --git a/test/metabase/premium_features/token_check_test.clj b/test/metabase/premium_features/token_check_test.cljindex 3e793b2d6a1..ee6370a50dc 100644--- a/test/metabase/premium_features/token_check_test.clj+++ b/test/metabase/premium_features/token_check_test.clj@@ -229,6 +229,29 @@(finally(token-check/-clear-cache! checker))))))+(deftest license-server-fields-we-do-not-read-test+ (testing "a token status response carrying fields we don't read still validates the token"+ (let [token (tu/random-token)+ body {:valid true+ :status "ok"+ :features ["sso-jwt"]+ :plan-alias "pro-self-hosted"+ :new-field "added by the license server"+ :store-users [{:email "[email protected]" :id 42 :first-name "Owner" :last-name "Person"}]+ :quotas [{:hosting-feature "metabase-ai-tokens"+ :soft-limit 100+ :usage 5+ :locked false+ :updated-at "2026-09-01T00:00:00Z"+ :quota-type "monthly"}]}+ checker (fresh-checker)]+ (try+ (mt/with-dynamic-fn-redefs [token-check/http-fetch (fn [& _] {:status 200 :body (json/encode body)})]+ (is (= (assoc body :canonical? true)+ (token-check/check-token checker token))))+ (finally+ (token-check/-clear-cache! checker))))))+(deftest ^:parallel extract-locks-test(testing "empty :meters map yields empty result"(is (= {} (#'token-check/extract-locks {}))))diff --git a/test/metabase/pulse/api/pulse_test.clj b/test/metabase/pulse/api/pulse_test.cljindex 301988a16b4..97ac40c07bf 100644--- a/test/metabase/pulse/api/pulse_test.clj+++ b/test/metabase/pulse/api/pulse_test.clj@@ -113,10 +113,7 @@{:cards (str "one or more value must be a map with the following keys ""`(collection_id, description, display, id, include_csv, include_xls, name, dashboard_id, parameter_mappings)`, ""or value must be a map with the keys `id`, `include_csv`, `include_xls`, and `dashboard_card_id`., "- "or value must be a map with the keys `include_csv`, `include_xls`, and `dashboard_card_id`., "- "or Schema for an instance of a `:model/Card`: every real column of `:report_card` (see `::card.update`) plus `:id`,\n"- " the `:persisted/*` columns some queries join in from `persisted_info`, and the keys some callers hydrate onto a\n"- " Card before passing it here.")}})+ "or value must be a map with the keys `include_csv`, `include_xls`, and `dashboard_card_id`.")}})(deftest create-pulse-validation-test(doseq [[input expected-error]@@ -156,6 +153,18 @@(is (=? expected-error(mt/user-http-request :rasta :post 400 "pulse" input))))))+(deftest create-pulse-rejects-card-without-export-flags-test+ (testing "POST /api/pulse rejects a card entry missing `include_csv` and `include_xls`"+ (is (=? {:errors {:cards {:include_csv #".*valid boolean.*"+ :include_xls #".*valid boolean.*"}}}+ (mt/user-http-request :rasta :post 400 "pulse" {:name "abc"+ :cards [{:id 100}]+ :channels [{:channel_type "email"+ :schedule_type "daily"+ :schedule_hour 12+ :enabled true+ :recipients []}]})))))+(defn- remove-extra-channels-fields [channels](for [channel channels](-> channel@@ -451,10 +460,7 @@{:cards (str "nullable one or more value must be a map with the following keys ""`(collection_id, description, display, id, include_csv, include_xls, name, dashboard_id, parameter_mappings)`, ""or value must be a map with the keys `id`, `include_csv`, `include_xls`, and `dashboard_card_id`., "- "or value must be a map with the keys `include_csv`, `include_xls`, and `dashboard_card_id`., "- "or Schema for an instance of a `:model/Card`: every real column of `:report_card` (see `::card.update`) plus `:id`,\n"- " the `:persisted/*` columns some queries join in from `persisted_info`, and the keys some callers hydrate onto a\n"- " Card before passing it here.")}})+ "or value must be a map with the keys `include_csv`, `include_xls`, and `dashboard_card_id`.")}})(deftest update-pulse-validation-test(testing "PUT /api/pulse/:id"diff --git a/test/metabase/queries_rest/api/card_test.clj b/test/metabase/queries_rest/api/card_test.cljindex 905ca288367..b38b9d91607 100644--- a/test/metabase/queries_rest/api/card_test.clj+++ b/test/metabase/queries_rest/api/card_test.clj@@ -1270,6 +1270,33 @@(is (= 1@called)))))))))+(deftest save-card-metadata-asynchronously-test+ (testing "POST and PUT /api/card save result metadata that is not ready within the sync wait once it is computed"+ (let [orig (mt/original-fn #'card.metadata/legacy-result-metadata-future)+ release (atom (promise))+ mp (mt/metadata-provider)]+ (mt/with-dynamic-fn-redefs [card.metadata/legacy-result-metadata-future (fn [query]+ (let [gate @release+ metadata (orig query)]+ (future @gate @metadata)))]+ (mt/with-model-cleanup [:model/Card]+ (let [saved-names (fn [card-id n]+ (map norm (u/poll {:thunk #(t2/select-one-fn :result_metadata :model/Card :id card-id)+ :done? #(= n (count %))+ :timeout-ms 10000+ :interval-ms 50})))+ card (mt/user-http-request :crowberto :post 200 "card"+ (card-with-name-and-query (mt/random-name)+ (lib/native-query mp "SELECT count(*) AS n FROM venues")))]+ (is (empty? (:result_metadata card)))+ (deliver @release true)+ (is (= ["N"] (saved-names (:id card) 1)))+ (reset! release (promise))+ (mt/user-http-request :crowberto :put 200 (str "card/" (:id card))+ {:dataset_query (lib/native-query mp "SELECT count(*) AS n, max(price) AS p FROM venues")})+ (deliver @release true)+ (is (= ["N" "P"] (saved-names (:id card) 2)))))))))+(deftest ^:parallel updating-card-updates-metadata-3(let [query (updating-card-updates-metadata-query)](testing "Patching the card _without_ the query does not clear the metadata"diff --git a/test/metabase/query_processor/card_test.clj b/test/metabase/query_processor/card_test.cljindex f0cdd969ba0..6daa199f351 100644--- a/test/metabase/query_processor/card_test.clj+++ b/test/metabase/query_processor/card_test.clj@@ -39,6 +39,15 @@(fn [query info](qp/process-query (assoc query :info info)))))))+(deftest empty-query-card-is-handed-to-the-runner-test+ (testing "a Card without a query is handed to the `:make-run` runner instead of being rejected as not found"+ (mt/test-driver :h2+ (mt/with-temp [:model/Card card {}]+ (is (=? {:viz-settings {}+ :middleware {:js-int-to-string? true}}+ (mt/as-admin+ (qp.card/process-query-for-card card :api :make-run (constantly (fn [query _info] query))))))))))+(defn field-filter-query"An MBQL 5 native query with a Field Filter (`:dimension`) parameter."[]diff --git a/test/metabase/slackbot/query_test.clj b/test/metabase/slackbot/query_test.cljindex 7e9c5c138a5..94f0e5af460 100644--- a/test/metabase/slackbot/query_test.clj+++ b/test/metabase/slackbot/query_test.clj@@ -3,6 +3,7 @@(:require[clojure.string :as str][clojure.test :refer :all]+ [metabase.config.core :as config][metabase.lib.core :as lib][metabase.lib.metadata :as lib.metadata][metabase.slackbot.query :as slackbot.query]@@ -81,6 +82,32 @@(testing "returns parseable PNG"(is (some? image)))))))+(deftest generate-adhoc-png-chart-with-report-timezone-test+ (testing "generate-adhoc-png renders a chart when a report timezone adds `:requested_timezone` to the results"+ (mt/with-temporary-setting-values [report-timezone "US/Pacific"]+ (mt/with-current-user (mt/user->id :rasta)+ (let [mp (mt/metadata-provider)+ query (-> (lib/query mp (lib.metadata/table mp (mt/id :venues)))+ (lib/aggregate (lib/count))+ (lib/breakout (lib.metadata/field mp (mt/id :venues :category_id))))+ results (slackbot.query/execute-adhoc-query query)]+ (is (= "US/Pacific" (get-in results [:data :requested_timezone])))+ (is (some? (bytes->image (#'slackbot.query/generate-adhoc-png results :bar)))))))))++(deftest generate-adhoc-png-chart-with-permissions-metadata-test+ (when config/ee-available?+ (testing "generate-adhoc-png renders a chart when EE permissions add `:download_perms` and `:is_sandboxed` to the results"+ (mt/with-premium-features #{:advanced-permissions :sandboxes}+ (mt/with-current-user (mt/user->id :rasta)+ (let [mp (mt/metadata-provider)+ query (-> (lib/query mp (lib.metadata/table mp (mt/id :venues)))+ (lib/aggregate (lib/count))+ (lib/breakout (lib.metadata/field mp (mt/id :venues :category_id))))+ results (slackbot.query/execute-adhoc-query query)]+ (is (= {:download_perms :full, :is_sandboxed false}+ (select-keys (:data results) [:download_perms :is_sandboxed])))+ (is (some? (bytes->image (#'slackbot.query/generate-adhoc-png results :bar))))))))))+(deftest generate-adhoc-png-line-chart-test(testing "generate-adhoc-png renders line chart visualization as PNG"(mt/dataset test-datadiff --git a/test/metabase/transforms/models/transform_test.clj b/test/metabase/transforms/models/transform_test.cljindex da750fa2743..cb0d6d26eb5 100644--- a/test/metabase/transforms/models/transform_test.clj+++ b/test/metabase/transforms/models/transform_test.clj@@ -1,6 +1,7 @@(ns metabase.transforms.models.transform-test(:require[clojure.test :refer :all]+ [java-time.api :as t][metabase.events.core :as events][metabase.lib.core :as lib][metabase.lib.metadata :as lib.metadata]@@ -218,6 +219,20 @@:query {:source-table (mt/id :people)}}}})(is (nil? (stored-deps id))))))+(deftest last-run-hydration-omits-heartbeat-test+ (testing "the `:last_run` hydrated onto a transform leaves out the run's internal `last_heartbeat`"+ (mt/with-temp [:model/Transform {transform-id :id} {}+ :model/TransformRun {run-id :id} {:transform_id transform-id+ :transform_name "heartbeat"+ :transform_entity_id "eid"+ :status "started"+ :is_active true+ :run_method "manual"+ :last_heartbeat (t/offset-date-time)}]+ (let [last-run (:last_run (t2/hydrate (t2/select-one :model/Transform transform-id) :last_run))]+ (is (=? {:id run-id, :transform_id transform-id} last-run))+ (is (not (contains? last-run :last_heartbeat)))))))+(deftest source-references-gate-transform-permissions-test(testing "A Card the source query names is required to read, write or create the transform"(mt/with-premium-features #{:transforms-basic :hosting}