Upgrading from 0.6.4 to 0.7.0-rc-2. Seeing unexpected response from io.pedestal.http/json-body.
:body seems to always be "", not the serialized JSON I expect.
It does an (assoc :body …) and I wonder if this should’ve been an (update :body …)?
I wanted to try putting my fix temporarily on Clojars. First, changed group from io.pedestal to no.terjesb in all deps.edn files. Second, changed group-name in build/build.clj. Then:
$ clojure -T:build deploy-all :dry-run true
Building version 0.7.0-SNAPSHOT (dry run) ...
common ...
telemetry ...
Execution error (ExceptionInfo) at clojure.tools.deps.extensions.maven/get-artifact (maven.clj:167).
Could not find artifact no.terjesb:pedestal.common:jar:0.7.0-SNAPSHOT in central ( )
It seems that the ‘common’ step there now did not actually install the jar locally with the new group-name:
# have ./common/target/pedestal.common-0.7.0-SNAPSHOT.jar
$ ls ~/.m2/repository/no/terjesb/pedestal.common/0.7.0-SNAPSHOT
resolver-status.properties
Inside deploy.clj, project-name is still io.pedestal/pedestal.common, the group-name change was not sufficient. Seems like it’s not able to pick the :project-name. Manually changing in deploy.clj works:
project-name (or (get-in basis [:io.pedestal/build :project-name])
(symbol "no.terjesb" (str "pedestal." dir)))
Now it worked as expected:
$ clojure -T:build deploy-all :dry-run true
Building version 0.7.0-SNAPSHOT (dry run) ...
common ...
telemetry ...
…
and actually installed locally under new group-name.
deploy-all now worked fine:)
$ CLOJARS_GPG_ID=.. CLOJARS_USERNAME=.. CLOJARS_PASSWORD=token clojure -T:build deploy-all
...
done
👍I noticed that after including my artifacts, it wouldn’t actually start:
Exception in thread "main" Syntax error macroexpanding at (io/pedestal/websocket.clj:1:1).
Caused by: java.lang.ClassNotFoundException: io.pedestal.websocket.FnEndpoint
Determined that FnEndpoint.class and ClojureVarServlet.class are missing from pedestal-service jar.
Turns out when I initially renamed group name io.pedestal in all deps.edn files, I accidentally also changed the :io.pedestal/build key in service/deps.edn, which compiles the Java sources.
After renaming this back to :io.pedestal/build and then re-deploying, the Java sources are compiled and things work again:)Yes, the build is a bit on the rickety side ... there's an issue on the first build because of cross-module dependencies. It gets the job done, though.
I've just pushed a fix for the json-body issue.
I'm going to tweak the deps-new template a little, and then do a deploy a new release candidate. May be a couple of days.
With 0.7.0, how can I package snapshot versions into local .m2 to test such a fix myself?
With 0.7.0, how can I package snapshot versions into local .m2 to test such a fix myself?Seems to be:
• changing VERSION.txt to 0.7.0-SNAPSHOT
◦ (edit: clojure -T:build update-version :version "0.7.0-SNAPSHOT" should probably be used to get all Pedestal artifacts to reference the snapshot — no, update-version doesn’t accept 0.7.0-SNAPSHOT
◦ clojure -T:build advance-version :dry-run true :level :snapshot seems to work)
• adding .cpcache to .gitignore
• clojure -T:build deploy-all :dry-run true
Yes, update seems to fix this:
diff --git a/service/src/io/pedestal/http.clj b/service/src/io/pedestal/http.clj
index c437862f..8724eba7 100644
--- a/service/src/io/pedestal/http.clj
+++ b/service/src/io/pedestal/http.clj
@@ -133,7 +133,7 @@
(fn [response]
(-> response
(ring-response/content-type "application/json;charset=UTF-8")
- (assoc :body response/stream-json)))))
+ (update :body response/stream-json)))))
in tests, clj -X:test
diff --git a/tests/test/io/pedestal/http_test.clj b/tests/test/io/pedestal/http_test.clj
index bc957279..0cb9fb47 100644
--- a/tests/test/io/pedestal/http_test.clj
+++ b/tests/test/io/pedestal/http_test.clj
@@ -172,7 +172,8 @@
(deftest json-body-test
(let [response (response-for (app) :get "/data-as-json")]
- (is (= "application/json;charset=UTF-8" (get-in response [:headers "Content-Type"])))))
+ (is (= "application/json;charset=UTF-8" (get-in response [:headers "Content-Type"])))
+ (is (= "{\"a\":1}" (get-in response [:body])))))Thanks for the heads up, I’ll look into this when I get back from vacation… and why it wasn’t caught by an existing test.