Skip to content

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

Allow config files to be named with a `.yaml` extension if no `.yml` file is found. (#77823)

Ethan McCuedec394cf5e3d
diff --git a/docs/configuring-metabase/config-file.md b/docs/configuring-metabase/config-file.md
index ee3e1762643..9a3238062f9 100644
--- a/docs/configuring-metabase/config-file.md
+++ b/docs/configuring-metabase/config-file.md
@@ -6,9 +6,9 @@ title: "Configuration file"
{% include plans-blockquote.html feature="Loading from a configuration file" self-hosted-only="true" %}
-On self-hosted [Pro](https://www.metabase.com/product/pro) and [Enterprise](https://www.metabase.com/product/enterprise) plans, Metabase supports initialization on launch from a config file named `config.yml`. The config file should be located at:
+On self-hosted [Pro](https://www.metabase.com/product/pro) and [Enterprise](https://www.metabase.com/product/enterprise) plans, Metabase supports initialization on launch from a config file. The config file should be located at:
-- The current directory (the directory where the running Metabase JAR is located).
+- A file named `config.yml` or `config.yaml` in the current directory (the directory where the running Metabase JAR is located).
- The path specified by the [`MB_CONFIG_FILE_PATH`](./environment-variables.md#mb_config_file_path) environment variable.
The settings in the config file work the same as if you'd set the settings in the Admin Settings in your Metabase. Settings defined in this configuration file will update any existing settings. If, for example, a database already exists (that is, you'd already added it via the initial set up or **Admin settings** > **Databases**, Metabase will update the database entry based on the data in the config file). Which means: if you define a setting in the config file, and then later change that setting in your Metabase application, keep in mind that the config file will overwrite that change whenever Metabase restarts. Let's reiterate that in a blockquote:
diff --git a/enterprise/backend/src/metabase_enterprise/advanced_config/file.clj b/enterprise/backend/src/metabase_enterprise/advanced_config/file.clj
index fa04e6961a3..2f30dcff2d1 100644
--- a/enterprise/backend/src/metabase_enterprise/advanced_config/file.clj
+++ b/enterprise/backend/src/metabase_enterprise/advanced_config/file.clj
@@ -96,6 +96,7 @@
[clojure.string :as str]
[clojure.walk :as walk]
[environ.core :as env]
+ [medley.core :as m]
[metabase-enterprise.advanced-config.file.api-keys]
[metabase-enterprise.advanced-config.file.databases]
[metabase-enterprise.advanced-config.file.interface :as advanced-config.file.i]
@@ -159,23 +160,24 @@
env/env)
(defn- path
- "Path for the YAML config file Metabase should use for initialization and Settings values.
-
- A blank `MB_CONFIG_FILE_PATH` counts as unset, consistent with [[metabase.config.core/config-str]]. (On JDK 25+ an
- empty path \"exists\" — it resolves to the current directory — so without this we would try to parse the current
- directory as YAML and fail to boot.)"
+ "Path for the YAML config file Metabase should use for initialization and Settings values."
^java.nio.file.Path []
- (let [env-path (get *env* :mb-config-file-path)
- path* (or (when-not (str/blank? env-path)
- (u.files/get-path env-path))
- (u.files/get-path (System/getProperty "user.dir") "config.yml"))]
- (if (u.files/exists? path*)
- (log/info (u/format-color :magenta
- "Found config file at path %s; Metabase will be initialized with values from this file"
- (pr-str (str path*)))
- (u/emoji "🗄️"))
- (log/info (u/format-color :yellow "No config file found at path %s" (pr-str (str path*)))))
- path*))
+ (let [configured-path (get *env* :mb-config-file-path)
+ default-config-yml (u.files/get-path (System/getProperty "user.dir") "config.yml")
+ default-config-yaml (u.files/get-path (System/getProperty "user.dir") "config.yaml")
+ paths-to-try (if-not (str/blank? configured-path)
+ [(u.files/get-path configured-path)]
+ [default-config-yml
+ default-config-yaml])]
+ (if-let [path* (m/find-first u.files/exists? paths-to-try)]
+ (u/prog1 path*
+ (log/info (u/format-color :magenta
+ "Found config file at path %s; Metabase will be initialized with values from this file"
+ (pr-str (str path*)))
+ (u/emoji "🗄️")))
+ (log/info (u/format-color :yellow "No config file found at path %s" (str/join " or "
+ (map #(pr-str (str %))
+ paths-to-try)))))))
(defmulti ^:private expand-parsed-template-form
{:arglists '([form])}
@@ -240,7 +242,8 @@
(defn- config-from-disk
"Read the config file from disk."
[]
- (yaml/from-file (str (path))))
+ (when-let [yaml-path (path)]
+ (yaml/from-file (str yaml-path))))
(defn- config
"Spec-validate `parsed-config` and (optionally) expand `{{env VAR}}` templates.
diff --git a/enterprise/backend/test/metabase_enterprise/advanced_config/file_test.clj b/enterprise/backend/test/metabase_enterprise/advanced_config/file_test.clj
index 666e2798087..13686bca988 100644
--- a/enterprise/backend/test/metabase_enterprise/advanced_config/file_test.clj
+++ b/enterprise/backend/test/metabase_enterprise/advanced_config/file_test.clj
@@ -7,7 +7,6 @@
[metabase-enterprise.advanced-config.file.interface :as advanced-config.file.i]
[metabase.test :as mt]
[metabase.util :as u]
- [metabase.util.files :as u.files]
[metabase.util.yaml :as yaml]))
(set! *warn-on-reflection* true)
@@ -36,8 +35,7 @@
(testing "A blank MB_CONFIG_FILE_PATH counts as unset (on JDK 25+ the empty path 'exists' as the current directory)"
(doseq [blank ["" " "]]
(binding [advanced-config.file/*env* (assoc @#'advanced-config.file/*env* :mb-config-file-path blank)]
- (is (= (str (u.files/get-path (System/getProperty "user.dir") "config.yml"))
- (str (#'advanced-config.file/path))))))))
+ (is (nil? (#'advanced-config.file/path)))))))
(deftest ^:parallel validate-config-test
(testing "Config should throw an error"
diff --git a/mage/src/mage/bot/server_info.clj b/mage/src/mage/bot/server_info.clj
index b9b8339ed09..c38a8ab1b22 100644
--- a/mage/src/mage/bot/server_info.clj
+++ b/mage/src/mage/bot/server_info.clj
@@ -25,7 +25,6 @@
(let [env (pr-env/load-pr-env)
token (pr-env/session-token)]
(print-git-branch)
-
(println "## Remote PR Environment")
(println)
(println "MODE=pr-env")
@@ -38,7 +37,6 @@
(println "API calls via `./bin/mage -bot-api-call` transparently target BASE_URL")
(println "using the cached session token — no code changes needed.")
(println)
-
(println "## REPL Access")
(println)
(println "NREPL_PORT=NONE")
@@ -51,7 +49,6 @@
(println "will NOT work here. Send ONE form per connection via `nc`. Wrap")
(println "multi-form work in `(do ...)`.")
(println)
-
(println "## Network")
(println)
(println "PR preview environments are only reachable via the Metabase Tailscale")
@@ -65,7 +62,6 @@
(let [resolved (bot-env/resolve-all)
config-path (get resolved "MB_CONFIG_FILE_PATH")]
(print-git-branch)
-
;; MB_* environment variables section
(println "## Environment Variables")
(println)
@@ -75,7 +71,6 @@
(println (str k "=" v)))
(println "No MB_* variables found.")))
(println)
-
;; Other useful variables
(println "## Other Variables")
(println)
@@ -86,7 +81,6 @@
v)]
(println (str var-name "=" display-v)))))
(println)
-
;; nREPL discovery — try clj-nrepl-eval first, fall back to reading
;; .nrepl-port directly (which Metabase's dev REPL writes on startup).
(println "## nREPL Servers")
@@ -106,7 +100,6 @@
port-from-file (println (str "NREPL_PORT=" port-from-file))
:else (println "NREPL_PORT=NONE")))
(println)
-
;; Source info
(println "## Sources")
(println)
@@ -121,7 +114,6 @@
(when has-lein?
(println "Also loaded: .lein-env")))
(println)
-
;; Config file section
(println "## Instance Configuration")
(println)
@@ -137,7 +129,9 @@
(println "The instance may not have pre-configured users. Check /api/setup to see if initial setup is needed."))))
;; MB_CONFIG_FILE_PATH not set — look for config files in well-known locations
(let [candidates [(str u/project-root-directory "/metabase.config.yml")
- (str u/project-root-directory "/local/config.yml")]
+ (str u/project-root-directory "/local/config.yml")
+ (str u/project-root-directory "/metabase.config.yaml")
+ (str u/project-root-directory "/local/config.yaml")]
found (first (filter #(.exists (java.io.File. ^String %)) candidates))]
(if found
(do