🐛 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
This commit is contained in:
Andrey Antukh 2026-10-07 13:33:33 +00:00
parent e4bf63cf89
commit c9fb11470b
2 changed files with 18 additions and 2 deletions

View File

@ -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)))

View File

@ -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)