diff --git a/src/metabase/api/card.clj b/src/metabase/api/card.clj index f2321d912a0895f5d5cc1b854705d728b5e45038..a7b5121df7982e682058d5c484dd0993f68b4fe0 100644 --- a/src/metabase/api/card.clj +++ b/src/metabase/api/card.clj @@ -195,6 +195,7 @@ ignore_view [:maybe :boolean]} (let [raw-card (t2/select-one Card :id id) card (-> raw-card + api/read-check (t2/hydrate :creator :dashboard_count :parameter_usage_count @@ -206,7 +207,6 @@ collection.root/hydrate-root-collection (cond-> ;; card (:dataset raw-card) (t2/hydrate :persisted)) - api/read-check (last-edit/with-last-edit-info :card))] (u/prog1 card (when-not ignore_view diff --git a/src/metabase/api/common.clj b/src/metabase/api/common.clj index d06df2f345e0d94c11533af2f3430397e5228bdf..ebabd98603833c85c4bcc250b433b991bfddd764 100644 --- a/src/metabase/api/common.clj +++ b/src/metabase/api/common.clj @@ -433,7 +433,7 @@ (catch clojure.lang.ExceptionInfo e ;; this is commented out until we write a handler to add this to the view_log #_(events/publish-event! :event/read-permission-failure {:user-id *current-user-id* - :object obj}) + :object obj}) (throw e))) obj) diff --git a/src/metabase/api/dashboard.clj b/src/metabase/api/dashboard.clj index 33ad8abb906fc27155c61a0b5d9a799cc4275b07..bbd77c5e9d83ef5fe89c868179c404989c5ae90d 100644 --- a/src/metabase/api/dashboard.clj +++ b/src/metabase/api/dashboard.clj @@ -183,7 +183,7 @@ "Get Dashboard with ID." [id] (-> (t2/select-one :model/Dashboard :id id) - api/check-404 + api/read-check ;; i'm a bit worried that this is an n+1 situation here. The cards can be batch hydrated i think because they ;; have a hydration key and an id. moderation_reviews currently aren't batch hydrated but i'm worried they ;; cannot be in this situation @@ -199,7 +199,6 @@ :param_values [:collection :is_personal]) collection.root/hydrate-root-collection - api/read-check api/check-not-archived hide-unreadable-cards add-query-average-durations)) diff --git a/test/metabase/api/card_test.clj b/test/metabase/api/card_test.clj index 580e58cee10d38be57ae80161fefa8e1bd036d9c..123eead1f62a0e99e379184114c8976ef7dcb061 100644 --- a/test/metabase/api/card_test.clj +++ b/test/metabase/api/card_test.clj @@ -1115,6 +1115,10 @@ :moderation_reviews (map clean))))))))))) +(deftest fetch-card-404-test + (testing "GET /api/card/:id" + (is (= "Not found." + (mt/user-http-request :crowberto :get 404 (format "card/%d" Integer/MAX_VALUE)))))) ;;; +----------------------------------------------------------------------------------------------------------------+ ;;; | UPDATING A CARD (PUT /api/card/:id) ;;; +----------------------------------------------------------------------------------------------------------------+ @@ -1122,7 +1126,7 @@ (deftest updating-a-card-that-doesnt-exist-should-give-a-404 (is (= "Not found." - (mt/user-http-request :crowberto :put 404 "card/12345")))) + (mt/user-http-request :crowberto :put 404 (format "card/%d" Integer/MAX_VALUE))))) (deftest test-that-we-can-edit-a-card (t2.with-temp/with-temp [:model/Card card {:name "Original Name"}]