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: Actions attached to models inside of Library(synced collection) break remote sync (#68252)
github-actions[bot]287665a6faf1
diff --git a/enterprise/backend/src/metabase_enterprise/remote_sync/impl.clj b/enterprise/backend/src/metabase_enterprise/remote_sync/impl.cljindex 6f17ff0308e..c51b848c5a3 100644--- a/enterprise/backend/src/metabase_enterprise/remote_sync/impl.clj+++ b/enterprise/backend/src/metabase_enterprise/remote_sync/impl.clj@@ -46,7 +46,8 @@[timestamp imported-entities-by-model table-paths field-paths](t2/delete! :model/RemoteSyncObject)(let [;; Standard models use entity_id UUIDs (excluding Segment which needs special handling)- standard-inserts (->> (dissoc imported-entities-by-model "Segment")+ ;; TODO(edpaget 2026-01-19): Actions are not dirty tracked+ standard-inserts (->> (dissoc imported-entities-by-model "Segment" "Action")(mapcat (fn [[model entity-ids]](when (seq entity-ids)(let [fields (model-fields-for-sync model)@@ -225,7 +226,7 @@:version (source.p/version snapshot):message (format "Skipping import: snapshot version %s matches last imported version" snapshot-version)}(log/infof (:message <>)))- (let [ingestable-snapshot (->> (source.p/->ingestable snapshot {:path-filters [#"collections/.*" #"databases/.*"]})+ (let [ingestable-snapshot (->> (source.p/->ingestable snapshot {:path-filters [#"collections/.*" #"databases/.*" #"actions/.*"]})(source.ingestable/wrap-progress-ingestable task-id 0.7))load-result (serdes/with-cache(serialization/load-metabase! ingestable-snapshot))diff --git a/enterprise/backend/test/metabase_enterprise/remote_sync/impl_test.clj b/enterprise/backend/test/metabase_enterprise/remote_sync/impl_test.cljindex 9ad21d8cf85..d8e35c01107 100644--- a/enterprise/backend/test/metabase_enterprise/remote_sync/impl_test.clj+++ b/enterprise/backend/test/metabase_enterprise/remote_sync/impl_test.clj@@ -916,3 +916,34 @@:model_id table-id:status "synced")"Table with schema should be tracked in RemoteSyncObject")))))))++(deftest import!-includes-actions-attached-to-models-test+ (testing "import! successfully imports Actions attached to Models in synced collections"+ (mt/with-model-cleanup [:model/RemoteSyncObject :model/Action]+ (let [task-id (t2/insert-returning-pk! :model/RemoteSyncTask {:sync_task_type "import" :initiated_by (mt/user->id :rasta)})]+ (mt/with-temp [:model/Collection {coll-id :id} {:name "Test Collection"+ :is_remote_synced true+ :entity_id "test-collection-1xxxx"+ :location "/"}+ :model/Card {model-id :id} {:name "Test Model"+ :entity_id "test-model-xxxxxxxxxx"+ :collection_id coll-id+ :type :model+ :dataset_query (mt/mbql-query venues)}]+ (let [test-files {"main" {"collections/test-collection-1xxxx-_/test-collection-1xxxx.yaml"+ (test-helpers/generate-collection-yaml "test-collection-1xxxx" "Test Collection")+ "collections/test-collection-1xxxx-_/cards/test-model.yaml"+ (test-helpers/generate-card-yaml "test-model-xxxxxxxxxx" "Test Model" "test-collection-1xxxx" "model")+ "actions/test-action-xxxxxxxxx_test_action.yaml"+ (test-helpers/generate-action-yaml "test-action-xxxxxxxxx" "Test Action" "test-model-xxxxxxxxxx")}}+ mock-source (test-helpers/create-mock-source :initial-files test-files)+ result (impl/import! (source.p/snapshot mock-source) task-id)]+ (is (= :success (:status result))+ "Import should succeed when actions/ directory is included in path filters")+ (let [imported-action (t2/select-one :model/Action :entity_id "test-action-xxxxxxxxx")]+ (is (some? imported-action)+ "Action should be imported successfully")+ (is (= "Test Action" (:name imported-action))+ "Action should have correct name")+ (is (= model-id (:model_id imported-action))+ "Action should be attached to the correct model"))))))))diff --git a/enterprise/backend/test/metabase_enterprise/remote_sync/test_helpers.clj b/enterprise/backend/test/metabase_enterprise/remote_sync/test_helpers.cljindex ba3e0f9e810..8f7977b34bb 100644--- a/enterprise/backend/test/metabase_enterprise/remote_sync/test_helpers.clj+++ b/enterprise/backend/test/metabase_enterprise/remote_sync/test_helpers.clj@@ -88,7 +88,7 @@ is_sample: falseReturns:A string containing the YAML representation of the card."- [entity-id name collection-id]+ [entity-id name collection-id & [type]](format "name: %sdescription: nullentity_id: %s@@ -121,10 +121,10 @@ archived_directly: falsedashboard_id: nullmetabase_version: v1.54.4-SNAPSHOT (c6780bb)source_card_id: null-type: question+type: %sdocument_id: null"- name entity-id collection-id entity-id (str/replace (u/lower-case-en name) #"\s+" "_")))+ name entity-id collection-id entity-id (str/replace (u/lower-case-en name) #"\s+" "_") (or type "question")))(defn generate-dashboard-yaml"Generates YAML content for a dashboard.@@ -511,3 +511,46 @@ serdes/meta:table-nameeid(str/replace (u/lower-case-en segment-name) #"\s+" "_"))))++(defn generate-action-yaml+ "Generates YAML content for an action.++ Args:+ entity-id: The unique identifier for the action.+ name: The name of the action.+ model-id: The entity ID of the model (Card) this action belongs to.++ Returns:+ A string containing the YAML representation of the action."+ [entity-id name model-id & {:keys [type kind]+ :or {type "implicit"+ kind "row/create"}}]+ (format "name: %s+description: null+entity_id: %s+created_at: '2024-08-28T09:46:24.692002Z'+creator_id: [email protected]+archived: false+model_id: %s+type: %s+parameters: []+parameter_mappings: []+visualization_settings:+ column_settings: null+public_uuid: null+made_public_by_id: null+%s+serdes/meta:+- id: %s+ label: %s+ model: Action+"+ name+ entity-id+ model-id+ type+ (if (= type "implicit")+ (format "implicit:\n- kind: %s\n" kind)+ "")+ entity-id+ (str/replace (u/lower-case-en name) #"\s+" "_")))