From c9fb11470b12e9cdf7101b61fa3fb3c7a8a5b33b Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 7 Oct 2026 13:33:33 +0000 Subject: [PATCH] :bug: Declare the transit content type on management calls Every poller turn died on `claim-job` with `missing-key` for `job-id` and `scheduled-at`: the JSON calls never declared their content type, so the backend never parsed the body as transit and validated an empty map. The header goes on the transit calls only; the multipart settle keeps the content type its own FormData settles. AI-assisted-by: glm-5.3-flash --- exporter/src/app/consumer/api.cljs | 7 +++++-- exporter/test/exporter_tests/api_test.cljs | 13 +++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/exporter/src/app/consumer/api.cljs b/exporter/src/app/consumer/api.cljs index 2c0f6ea654..f7c7ffa93e 100644 --- a/exporter/src/app/consumer/api.cljs +++ b/exporter/src/app/consumer/api.cljs @@ -69,11 +69,14 @@ :response body))))))))) (defn- request - "POST `params` to a management method as transit+json." + "POST `params` to a management method as transit+json. The content + type travels on every call: without it the backend never parses the + body as transit and validates an empty map." [method params] (->> (fetch (method-uri method) #js {:method "POST" - :headers (shared-key) + :headers (doto (shared-key) + (unchecked-set "Content-Type" "application/transit+json")) :body (t/encode-str params) :dispatcher (dispatcher)}) (p/mcat parse-response))) diff --git a/exporter/test/exporter_tests/api_test.cljs b/exporter/test/exporter_tests/api_test.cljs index b2953659ba..3fae29bd9f 100644 --- a/exporter/test/exporter_tests/api_test.cljs +++ b/exporter/test/exporter_tests/api_test.cljs @@ -95,6 +95,19 @@ restore! done)))) +(t/deftest json-calls-declare-the-transit-content-type + ;; without it the backend never parses the body as transit and + ;; validates an empty map (every key a `missing-key`) + (t/async done + (let [restore! (install-fetch!)] + (with-restore-and-done + (p/fmap (fn [_] + (t/is (= "application/transit+json" + (fetch-header "Content-Type")))) + (api/claim-job (uuid/next) "2026-10-07T00:00:00Z")) + restore! + done)))) + (t/deftest report-job-progress-posts-the-beat (t/async done (let [job-id (uuid/next)