diff --git a/backend/src/app/rpc/queries/profile.clj b/backend/src/app/rpc/queries/profile.clj index b68c6a5f17..a3ca758f5e 100644 --- a/backend/src/app/rpc/queries/profile.clj +++ b/backend/src/app/rpc/queries/profile.clj @@ -37,10 +37,15 @@ (sv/defmethod ::profile {:auth false} [{:keys [pool] :as cfg} {:keys [profile-id] :as params}] - (if profile-id - (retrieve-profile pool profile-id) - {:id uuid/zero - :fullname "Anonymous User"})) + + ;; We need to return the anonymous profile object in two cases, when + ;; no profile-id is in session, and when db call raises not found. In all other + ;; cases we need to reraise the exception. + (or (ex/try* + #(some->> profile-id (retrieve-profile pool)) + #(when (not= :not-found (:type (ex-data %))) (throw %))) + {:id uuid/zero + :fullname "Anonymous User"})) (def ^:private sql:default-profile-team "select t.id, name diff --git a/backend/test/app/services_profile_test.clj b/backend/test/app/services_profile_test.clj index b51bcd8c0f..ba82c0f0e8 100644 --- a/backend/test/app/services_profile_test.clj +++ b/backend/test/app/services_profile_test.clj @@ -6,6 +6,7 @@ (ns app.services-profile-test (:require + [app.common.uuid :as uuid] [app.db :as db] [app.rpc.mutations.profile :as profile] [app.test-helpers :as th] @@ -153,11 +154,8 @@ :profile-id (:id prof)} out (th/query! params)] ;; (th/print-result! out) - (let [error (:error out) - error-data (ex-data error)] - (t/is (th/ex-info? error)) - (t/is (= (:type error-data) :not-found)))) - )) + (let [result (:result out)] + (t/is (= uuid/zero (:id result))))))) (t/deftest registration-domain-whitelist (let [whitelist #{"gmail.com" "hey.com" "ya.ru"}]