From 47f80cf3dbb743648a9f9c0fa0b03b7ca0e1ffba Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 1 Apr 2025 12:30:51 +0200 Subject: [PATCH 1/4] :bug: Make error middleware capture profile-id --- backend/src/app/http.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/app/http.clj b/backend/src/app/http.clj index e04b0523df..0668a4a0b2 100644 --- a/backend/src/app/http.clj +++ b/backend/src/app/http.clj @@ -156,9 +156,9 @@ [mw/params] [mw/format-response] [mw/parse-request] - [mw/errors errors/handle] [session/soft-auth cfg] [actoken/soft-auth cfg] + [mw/errors errors/handle] [mw/restrict-methods]]} (::mtx/routes cfg) From 3ec797f56ebd5a5c89a48f65f114bdf50b4ca6a7 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 1 Apr 2025 19:16:35 +0200 Subject: [PATCH 2/4] :bug: Validate and decode params on export-binfile --- backend/src/app/rpc/commands/binfile.clj | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/backend/src/app/rpc/commands/binfile.clj b/backend/src/app/rpc/commands/binfile.clj index 49ab841931..04f550676c 100644 --- a/backend/src/app/rpc/commands/binfile.clj +++ b/backend/src/app/rpc/commands/binfile.clj @@ -38,7 +38,6 @@ (def ^:private schema:export-binfile [:map {:title "export-binfile"} - [:name [:string {:max 250}]] [:file-id ::sm/uuid] [:version {:optional true} ::sm/int] [:include-libraries ::sm/boolean] @@ -78,7 +77,7 @@ "Export a penpot file in a binary format." {::doc/added "1.15" ::webhooks/event? true - ::sm/result schema:export-binfile} + ::sm/params schema:export-binfile} [{:keys [::db/pool] :as cfg} {:keys [::rpc/profile-id version file-id] :as params}] (files/check-read-permissions! pool profile-id file-id) (fn [_] From 4d4a04e9aa3dcae83a82f03cb79a6f77863a61a6 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 1 Apr 2025 20:24:07 +0200 Subject: [PATCH 3/4] :sparkles: Add minor enhacement for error reporting --- backend/src/app/http/errors.clj | 7 ++++--- backend/src/app/loggers/database.clj | 7 ++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/backend/src/app/http/errors.clj b/backend/src/app/http/errors.clj index 35e58bbca1..9647ecec29 100644 --- a/backend/src/app/http/errors.clj +++ b/backend/src/app/http/errors.clj @@ -62,7 +62,8 @@ ::yres/body data} (binding [l/*context* (request->context request)] - (l/err :hint "restriction error" :data data) + (l/err :hint "restriction error" + :cause err) {::yres/status 400 ::yres/body data})))) @@ -102,7 +103,7 @@ (= code :invalid-image) (binding [l/*context* (request->context request)] (let [cause (or parent-cause err)] - (l/warn :hint "unexpected error on processing image" :cause cause) + (l/warn :hint "image process error" :cause cause) {::yres/status 400 ::yres/body data})) :else @@ -177,7 +178,7 @@ (let [state (.getSQLState ^java.sql.SQLException error) cause (or parent-cause error)] (binding [l/*context* (request->context request)] - (l/error :hint "PSQL error" + (l/error :hint "postgresql error" :cause cause) (cond (= state "57014") diff --git a/backend/src/app/loggers/database.clj b/backend/src/app/loggers/database.clj index 41584eddca..196845a967 100644 --- a/backend/src/app/loggers/database.clj +++ b/backend/src/app/loggers/database.clj @@ -53,11 +53,16 @@ (assoc :logger/name logger) (assoc :logger/level level) (dissoc :request/params :value :params :data))] + (merge {:context (-> (into (sorted-map) ctx) (pp/pprint-str :length 50)) :props (pp/pprint-str props :length 50) - :hint (or (ex-message cause) @message) + :hint (or (when-let [message (ex-message cause)] + (if-let [props-hint (:hint props)] + (str props-hint ": " message) + message)) + @message) :trace (or (::trace record) (some-> cause (ex/format-throwable :data? false :explain? false :header? false :summary? false)))} From 5d600c6715c37c27871a56091863fdf5b9736efc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Moya?= Date: Wed, 2 Apr 2025 09:41:12 +0200 Subject: [PATCH 4/4] :sparkles: Change behavior of single set json file import to be coherent (#6211) --- .../src/app/main/ui/workspace/tokens/style_dictionary.cljs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/frontend/src/app/main/ui/workspace/tokens/style_dictionary.cljs b/frontend/src/app/main/ui/workspace/tokens/style_dictionary.cljs index a31f0635ac..d04ed352e9 100644 --- a/frontend/src/app/main/ui/workspace/tokens/style_dictionary.cljs +++ b/frontend/src/app/main/ui/workspace/tokens/style_dictionary.cljs @@ -6,7 +6,6 @@ [app.common.schema :as sm] [app.common.transit :as t] [app.common.types.tokens-lib :as ctob] - [app.main.refs :as refs] [app.main.ui.workspace.tokens.errors :as wte] [app.main.ui.workspace.tokens.tinycolor :as tinycolor] [app.main.ui.workspace.tokens.token :as wtt] @@ -268,11 +267,11 @@ (cond (and single-set? (= :json-format/legacy json-format)) - (ctob/decode-single-set-legacy-json (ctob/ensure-tokens-lib (deref refs/tokens-lib)) file-name json-data) + (ctob/decode-single-set-legacy-json (ctob/ensure-tokens-lib nil) file-name json-data) (and single-set? (= :json-format/dtcg json-format)) - (ctob/decode-single-set-json (ctob/ensure-tokens-lib (deref refs/tokens-lib)) file-name json-data) + (ctob/decode-single-set-json (ctob/ensure-tokens-lib nil) file-name json-data) (= :json-format/legacy json-format) (ctob/decode-legacy-json (ctob/ensure-tokens-lib nil) json-data)