Skip to content

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

GHY-3701 force let-user-control-scheduling false in workspace config (#74913)

Eric Normanddd9d119b4c1c
diff --git a/enterprise/backend/src/metabase_enterprise/workspaces/config.clj b/enterprise/backend/src/metabase_enterprise/workspaces/config.clj
index e8546556839..78cdffc6bf5 100644
--- a/enterprise/backend/src/metabase_enterprise/workspaces/config.clj
+++ b/enterprise/backend/src/metabase_enterprise/workspaces/config.clj
@@ -51,9 +51,14 @@
(defn- database-entry [wsd db]
{:name (:name db)
:engine (:engine db)
+ ;; Force :let-user-control-scheduling false. The YAML only carries :details — not the
+ ;; cache_field_values_schedule / metadata_sync_schedule columns — and infer-db-schedules
+ ;; asserts those columns are present whenever user-control scheduling is on. Without
+ ;; this override the round-trip blows up for any DB whose source details opted in.
:details (merge (:details db)
(:database_details wsd)
- (schema-filter-entries db wsd))})
+ (schema-filter-entries db wsd)
+ {:let-user-control-scheduling false})})
(defn- expand-output
"Expand a driver-opaque `output_namespace` string into the `{:db ?, :schema ?}`
diff --git a/enterprise/backend/test/metabase_enterprise/workspaces/config_test.clj b/enterprise/backend/test/metabase_enterprise/workspaces/config_test.clj
index a676133c245..c8114f7722a 100644
--- a/enterprise/backend/test/metabase_enterprise/workspaces/config_test.clj
+++ b/enterprise/backend/test/metabase_enterprise/workspaces/config_test.clj
@@ -37,13 +37,14 @@
(is (= "Analytics Data Warehouse" (:name db)))
(is (= :postgres (:engine db)))
(testing "original details are preserved, workspace overrides win, schema-filters appended"
- (is (= {:host "mbdata.metabase.com"
- :port 5432
- :user "mb_isolation_github"
- :password "secret"
- :dbname "stitchdata_incoming"
- :schema-filters-type "inclusion"
- :schema-filters-patterns "raw_github"}
+ (is (= {:host "mbdata.metabase.com"
+ :port 5432
+ :user "mb_isolation_github"
+ :password "secret"
+ :dbname "stitchdata_incoming"
+ :schema-filters-type "inclusion"
+ :schema-filters-patterns "raw_github"
+ :let-user-control-scheduling false}
(:details db))))))
(testing "workspace entry uses flat input_schemas + expanded :output map"
(is (= "github" (-> cfg :config :workspace :name)))
@@ -191,6 +192,33 @@
(mt/with-model-cleanup [:model/Workspace]
(is (nil? (config/build-workspace-config Integer/MAX_VALUE))))))
+(deftest build-workspace-config-forces-let-user-control-scheduling-false-test
+ (testing "Non-stub database entries emit :let-user-control-scheduling false even if the source
+ database had it true. The YAML carries :details only — not the schedule cron columns —
+ so on import infer-db-schedules must take the auto-schedule branch instead of asserting
+ on missing cache_field_values_schedule / metadata_sync_schedule."
+ (mt/with-temp [:model/Database {db-id :id}
+ {:name "User-Scheduled DW"
+ :engine :postgres
+ :details {:host "h"
+ :port 5432
+ :let-user-control-scheduling true}}
+ :model/Workspace {ws-id :id} {:name "sched"
+ :creator_id (mt/user->id :crowberto)}
+ :model/WorkspaceDatabase _
+ {:workspace_id ws-id
+ :database_id db-id
+ :database_details {:user "u" :password "p"}
+ :output_namespace "ws_alice"
+ :input_schemas ["public"]
+ :status :provisioned}]
+ (let [own-db (->> (config/build-workspace-config ws-id)
+ :config
+ :databases
+ (remove (some-fn :is_stub :is_sample))
+ first)]
+ (is (false? (get-in own-db [:details :let-user-control-scheduling])))))))
+
(deftest build-workspace-config-emits-sample-database-test
(testing "When a Sample Database exists in the instance, /config emits an entry with
standardized name/engine, empty :details, and :is_sample true. The entry is