From 32700730ad3ed1b41c02132e100df6f3776a4bed Mon Sep 17 00:00:00 2001
From: Cam Saul <cammsaul@gmail.com>
Date: Wed, 2 Jan 2019 16:34:29 -0800
Subject: [PATCH] Make sure Max Cache Entry Size setting handles string inputs
 correctly

---
 src/metabase/public_settings.clj       | 5 ++++-
 test/metabase/public_settings_test.clj | 7 +++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/metabase/public_settings.clj b/src/metabase/public_settings.clj
index 897e1d438bc..507c5346cc3 100644
--- a/src/metabase/public_settings.clj
+++ b/src/metabase/public_settings.clj
@@ -108,7 +108,10 @@
   :type    :integer
   :default 1000
   :setter  (fn [new-value]
-             (when (> new-value global-max-caching-kb)
+             (when (and new-value
+                        (> (cond-> new-value
+                             (string? new-value) Integer/parseInt)
+                           global-max-caching-kb))
                (throw (IllegalArgumentException.
                        (str
                         (tru "Failed setting `query-caching-max-kb` to {0}." new-value)
diff --git a/test/metabase/public_settings_test.clj b/test/metabase/public_settings_test.clj
index dd3badfd9e8..f5914711b63 100644
--- a/test/metabase/public_settings_test.clj
+++ b/test/metabase/public_settings_test.clj
@@ -49,3 +49,10 @@
     (i18n/with-user-locale zz
       [(= zz (i18n/user-locale))
        (tru "Host")])))
+
+;; Make sure Max Cache Entry Size can be set via with a string value, which is what comes back from the API (#9143)
+(expect
+  "1000"
+  ;; use with temp value macro so original value gets reset after test run
+  (tu/with-temporary-setting-values [query-caching-max-kb nil]
+    (public-settings/query-caching-max-kb "1000")))
-- 
GitLab