Skip to content

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

[serdes] report local PK for entity when loading fails (#62205)

Oleksandr Solovyov57e37a6773de
diff --git a/deps.edn b/deps.edn
index 14545af7fd8..d72f817e10b 100644
--- a/deps.edn
+++ b/deps.edn
@@ -250,7 +250,6 @@
{:mvn/version "0.4.0"} ; Enables easy memory measurement
com.gfredericks/test.chuck {:mvn/version "0.2.15"} ; generating strings from regexes (useful with malli)
criterium/criterium {:mvn/version "0.4.6"} ; benchmarking library
- dev.weavejester/hashp {:mvn/version "0.4.0"} ; debugging/spying utility
djblue/portal {:mvn/version "0.60.2"} ; ui for inspecting values
io.github.camsaul/humane-are {:mvn/version "1.0.2"} ; cleaner test output
io.github.metabase/hawk {:sha "1fe839cfa48549e21b89c6418c747895eda7e7bc"} ; test runner
diff --git a/enterprise/backend/src/metabase_enterprise/serialization/v2/load.clj b/enterprise/backend/src/metabase_enterprise/serialization/v2/load.clj
index d5fc48fc469..743e776f96f 100644
--- a/enterprise/backend/src/metabase_enterprise/serialization/v2/load.clj
+++ b/enterprise/backend/src/metabase_enterprise/serialization/v2/load.clj
@@ -60,6 +60,8 @@
(defn- path-error-data [error-type expanding path]
(let [last-model (:model (last path))]
{:path (mapv (partial into {}) path)
+ :local-id (when-let [entity (serdes/load-find-local path)]
+ ((t2/select-pks-fn entity) entity))
:deps-chain expanding
:model last-model
:table (some->> last-model (keyword "model") t2/table-name)
diff --git a/enterprise/backend/test/metabase_enterprise/serialization/api_test.clj b/enterprise/backend/test/metabase_enterprise/serialization/api_test.clj
index acec14ddc81..486e2aa8510 100644
--- a/enterprise/backend/test/metabase_enterprise/serialization/api_test.clj
+++ b/enterprise/backend/test/metabase_enterprise/serialization/api_test.clj
@@ -278,6 +278,7 @@
:error :metabase-enterprise.serialization.v2.load/not-found,
:model "Collection",
:path [{:id "DoesNotExist", :model "Collection"}],
+ :local-id nil
:table :collection}
(extract-and-sanitize-exception-map log))))
(testing "Snowplow event about error was sent"
diff --git a/src/metabase/collections/models/collection.clj b/src/metabase/collections/models/collection.clj
index 387bf973ce3..777540cb978 100644
--- a/src/metabase/collections/models/collection.clj
+++ b/src/metabase/collections/models/collection.clj
@@ -614,7 +614,7 @@
[:= :p.perm_value (h2x/literal "read")])]]}]}
{:select [:c.id :c.location :c.archived :c.archive_operation_id :c.archived_directly]
:from [[:collection :c]]
- :where [:= :type (h2x/literal "trash")]}
+ :where [:= :type (h2x/literal trash-collection-type)]}
(when-let [personal-collection-and-descendant-ids
(seq (user->personal-collection-and-descendant-ids current-user-id))]
{:select [:c.id :c.location :c.archived :c.archive_operation_id :c.archived_directly]