fix: upsert page property options can't handle user properties

Fails with 'unknown built-in' error instead of just handling it.
Also fix an incorrect test teardown from previous commit
This commit is contained in:
Gabriel Horner
2026-03-26 17:33:19 -04:00
parent 8732d947fb
commit 29a7a77a6b
3 changed files with 28 additions and 5 deletions

View File

@@ -195,9 +195,13 @@
(let [id (:id options)
page (some-> (:page options) string/trim)
update-tags-result (add-command/parse-tags-option (:update-tags options))
update-properties-result (add-command/parse-properties-option (:update-properties options))
update-properties-result (add-command/parse-properties-option
(:update-properties options)
{:allow-non-built-in? true})
remove-tags-result (add-command/parse-tags-vector-option (:remove-tags options))
remove-properties-result (add-command/parse-properties-vector-option (:remove-properties options))
remove-properties-result (add-command/parse-properties-vector-option
(:remove-properties options)
{:allow-non-built-in? true})
invalid-message (invalid-options? :upsert-page options)]
(cond
(seq invalid-message)
@@ -541,9 +545,11 @@
block-ids [page-id]
update-tags (add-command/resolve-tags cfg (:repo action) (:update-tags action))
remove-tags (add-command/resolve-tags cfg (:repo action) (:remove-tags action))
update-properties (add-command/resolve-properties cfg (:repo action) (:update-properties action))
update-properties (add-command/resolve-properties cfg (:repo action) (:update-properties action)
{:allow-non-built-in? false})
remove-properties (add-command/resolve-property-identifiers cfg (:repo action)
(:remove-properties action))
(:remove-properties action)
{:allow-non-built-in? false})
_ (ensure-property-identifiers-exist! cfg (:repo action) (keys (or update-properties {})))
_ (ensure-property-identifiers-exist! cfg (:repo action) remove-properties)
update-tag-ids (->> (or update-tags [])

View File

@@ -2399,6 +2399,23 @@
(p/catch (fn [e] (is false (str "unexpected error: " e))))
(p/finally done)))))
(deftest test-build-action-upsert-page-accepts-user-property
(testing "upsert page accepts user property key in update-properties"
(let [parsed (commands/parse-args ["upsert" "page"
"--page" "Home"
"--update-properties" "{\"p1\" \"default\"}"])
result (commands/build-action parsed {:graph "demo"})]
(is (true? (:ok? result)))
(is (some? (get-in result [:action :update-properties])))))
(testing "upsert page accepts user property key in remove-properties"
(let [parsed (commands/parse-args ["upsert" "page"
"--page" "Home"
"--remove-properties" "[\"p1\"]"])
result (commands/build-action parsed {:graph "demo"})]
(is (true? (:ok? result)))
(is (some? (get-in result [:action :remove-properties]))))))
(deftest test-execute-upsert-page-errors-when-property-does-not-exist
(async done
(let [action {:type :upsert-page :repo "demo" :page "Home"

View File

@@ -127,4 +127,4 @@
(is (not (string/includes? (:output result) "at "))
"output should not contain a stack trace")))
(p/catch (fn [e] (is false (str "unexpected error: " e))))
(p/finally (done)))))
(p/finally (fn [] (done))))))