`d/with` fails with :cognitect.anomalies/incorrect

d/transact works fine, but I can’t get d/with to work, even with an empty transaction:

=> (d/with (d/db conn) {:tx-data []})
ExceptionInfo Datomic Client Exception  clojure.core/ex-info (core.clj:4739)

=> (pprint (ex-data *e))
{:cognitect.anomalies/category :cognitect.anomalies/incorrect,
 {:status 400,
  {"content-length" "220",
   "server" "Jetty(9.3.7.v20160115)",
   "date" "Tue, 07 May 2019 01:17:01 GMT",
   "content-type" "application/transit+msgpack"},
  :body nil}}

How do I troubleshoot this?

This is using :server-type :ion, by the way. See https://github.com/jacobobryant/d-with-error for a MWE.

I believe d/with takes a transaction like [[:db/add e a v] …], not a map with :tx-data

That’s true for the peer api but not for the client api (which is what I’m using).

I figured it out. I was supposed to use d/with-db, not d/db (i.e. (d/with (d/with-db conn) {:tx-data []})). I had been using on-prem previously and only noticed this difference just now from looking at (doc d/with).

A better error message would’ve been really helpful here; something like “invalid DB; must use return value from datomic.client.api/with-db”.