cognitect-labs / vase

Data driven microservices
Eclipse Public License 1.0
374 stars 40 forks source link

your_first_api.md edits #32

Closed mchampine closed 7 years ago

mchampine commented 7 years ago

Description

Given a route:

"/do-stuff" {:post #vase/transact {:name :example/do-stuff-to-things
                                   :properties [:a :b]}

Trying to run invoke a transaction

"curl -H "Content-Type: application/json" -X POST -d '{"payload": [{"a": "Hello", "b": "World"}]}' http://localhost:8080/api/example/do-stuff"

results in an exception

Expected Behavior

"When the transaction executes, it will create a new entity in Datomic with the entity map {:a "Hello" :b "World"}"

Actual Behavior

clojure.lang.ExceptionInfo: Interceptor Exception: java.lang.IllegalArgumentException: :db.error/not-an-entity Unable to resolve entity: :a

(full trace below)

Steps to reproduce

use the route and http request as shown above.

Operating System (including version).

os x 10.9.5

Your current Leiningen/Boot/Maven version (lein --version)

Leiningen 2.7.1 on Java 1.8.0_40 Java HotSpot(TM) 64-Bit Server VM

Pedestal and Vase version

project.clj defaults from "lein new vase

Full Error Trace

ERROR i.p.http.impl.servlet-interceptor - {:msg "error-ring-response triggered", :context {:response nil, :io.pedestal.interceptor.chain/stack (#Interceptor{:name :io.pedestal.http.impl.servlet-interceptor/stylobate} #Interceptor{:name :io.pedestal.http.impl.servlet-interceptor/terminator-injector}), :request {:request-id "YlgEGRMLPxE", :json-params {:payload [{:a "xxx", :b "yyy"}]}, :protocol "HTTP/1.1", :db datomic.db.Db@ace8a948, :async-supported? true, :remote-addr "127.0.0.1", :servlet-response #object[org.eclipse.jetty.server.Response 0x79d7c641 "HTTP/1.1 200 \nDate: Tue, 07 Feb 2017 05:39:03 GMT\r\n\r\n"], :servlet #object[io.pedestal.http.servlet.FnServlet 0x18bef68d "io.pedestal.http.servlet.FnServlet@18bef68d"], :headers {"user-agent" "curl/7.30.0", "host" "localhost:8080", "accept" "/", "content-length" "36", "content-type" "application/json", "vaserequest-id" "YlgEGRMLPxE"}, :server-port 8080, :servlet-request #object[org.eclipse.jetty.server.Request 0x1a098c30 "Request(POST //localhost:8080/api/accounts/v1/dostuff)@1a098c30"], :content-length 36, :content-type "application/json", :path-info "/api/accounts/v1/dostuff", :character-encoding "UTF-8", :received-time #object[org.joda.time.DateTime 0x2dc42ba1 "2017-02-07T05:39:03.697Z"], :url-for #object[io.pedestal.http.route$url_for_routes$fn9809 0x2dd7f1f6 "io.pedestal.http.route$url_for_routes$fn9809@2dd7f1f6"], :uri "/api/accounts/v1/dostuff", :server-name "localhost", :query-string nil, :path-params {}, :body #object[org.eclipse.jetty.server.HttpInputOverHTTP 0x4ffffc23 "HttpInputOverHTTP@4ffffc23[c=36,q=0,[0]=null,s=STREAM]"], :scheme :http, :request-method :post, :conn #object[datomic.peer.LocalConnection 0x70a9b689 "datomic.peer.LocalConnection@70a9b689"]}, :bindings {#'io.pedestal.http.route/url-for #object[io.pedestal.http.route$url_for_routes$fn9809 0x2dd7f1f6 "io.pedestal.http.route$url_for_routes$fn9809@2dd7f1f6"]}, :enter-async [#object[io.pedestal.http.impl.servlet_interceptor$start_servlet_async 0x32b1e8c4 "io.pedestal.http.impl.servlet_interceptor$start_servlet_async@32b1e8c4"]], :io.pedestal.interceptor.chain/terminators (#object[io.pedestal.http.impl.servlet_interceptor$terminator_inject$fn12757 0x34ab12f7 "io.pedestal.http.impl.servlet_interceptor$terminator_inject$fn12757@34ab12f7"]), :servlet-response #object[org.eclipse.jetty.server.Response 0x79d7c641 "HTTP/1.1 200 \nDate: Tue, 07 Feb 2017 05:39:03 GMT\r\n\r\n"], :route {:path "/api/accounts/v1/dostuff", :method :post, :path-re #"/\Qapi\E/\Qaccounts\E/\Qv1\E/\Qdostuff\E", :path-parts ["api" "accounts" "v1" "dostuff"], :interceptors [#Interceptor{:name :attach-received-time} #Interceptor{:name :attach-request-id} #Interceptor{:name :io.pedestal.http/json-body} #Interceptor{:name :com.cognitect.vase.datomic/insert-datomic} #Interceptor{:name :io.pedestal.http.body-params/body-params} #Interceptor{:name :forward-headers} #Interceptor{:name :accounts.v1/dostuff}], :route-name :accounts.v1/dostuff, :path-params {}, :io.pedestal.http.route.prefix-tree/satisfies-constraints? #object[clojure.core$constantly$fn6693 0x7316ad67 "clojure.core$constantly$fn6693@7316ad67"]}, :servlet #object[io.pedestal.http.servlet.FnServlet 0x18bef68d "io.pedestal.http.servlet.FnServlet@18bef68d"], :servlet-request #object[org.eclipse.jetty.server.Request 0x1a098c30 "Request(POST //localhost:8080/api/accounts/v1/dostuff)@1a098c30"], :url-for #object[io.pedestal.http.route$url_for_routes$fn9809 0x2dd7f1f6 "io.pedestal.http.route$url_for_routes$fn9809@2dd7f1f6"], :io.pedestal.interceptor.chain/execution-id 1, :servlet-config #object[org.eclipse.jetty.servlet.ServletHolder$Config 0x6335c430 "org.eclipse.jetty.servlet.ServletHolder$Config@6335c430"], :async? #object[io.pedestal.http.impl.servlet_interceptor$servlet_asyncQMARK 0x763d616c "io.pedestal.http.impl.servlet_interceptor$servlet_asyncQMARK@763d616c"]}, :line 252} clojure.lang.ExceptionInfo: Interceptor Exception: java.lang.IllegalArgumentException: :db.error/not-an-entity Unable to resolve entity: :a at clojure.core$ex_info.invokeStatic(core.clj:4725) at clojure.core$ex_info.invoke(core.clj:4725) at io.pedestal.interceptor.chain$throwableGT_ex_info.invokeStatic(chain.clj:33) at io.pedestal.interceptor.chain$throwableGT_ex_info.invoke(chain.clj:32) at io.pedestal.interceptor.chain$try_f.invokeStatic(chain.clj:55) at io.pedestal.interceptor.chain$try_f.invoke(chain.clj:42) at io.pedestal.interceptor.chain$process_all_with_binding.invokeStatic(chain.clj:169) at io.pedestal.interceptor.chain$process_all_with_binding.invoke(chain.clj:144) at io.pedestal.interceptor.chain$process_all$fn8786.invoke(chain.clj:186) at clojure.lang.AFn.applyToHelper(AFn.java:152) at clojure.lang.AFn.applyTo(AFn.java:144) at clojure.core$apply.invokeStatic(core.clj:657) at clojure.core$with_bindingsSTAR.invokeStatic(core.clj:1963) at clojure.core$with_bindingsSTAR.doInvoke(core.clj:1963) at clojure.lang.RestFn.invoke(RestFn.java:425) at io.pedestal.interceptor.chain$process_all.invokeStatic(chain.clj:184) at io.pedestal.interceptor.chain$process_all.invoke(chain.clj:180) at io.pedestal.interceptor.chain$enter_all.invokeStatic(chain.clj:233) at io.pedestal.interceptor.chain$enter_all.invoke(chain.clj:227) at io.pedestal.interceptor.chain$execute.invokeStatic(chain.clj:377) at io.pedestal.interceptor.chain$execute.invoke(chain.clj:350) at io.pedestal.interceptor.chain$execute.invokeStatic(chain.clj:387) at io.pedestal.interceptor.chain$execute.invoke(chain.clj:350) at io.pedestal.http.impl.servlet_interceptor$interceptor_service_fn$fn12782.invoke(servlet_interceptor.clj:350) at io.pedestal.http.servlet.FnServlet.service(servlet.clj:28) at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:838) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:543) at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:188) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1228) at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:168) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:481) at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:166) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1130) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132) at org.eclipse.jetty.server.Server.handle(Server.java:564) at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:318) at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251) at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279) at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:112) at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:672) at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:590) at java.lang.Thread.run(Thread.java:745) Caused by: java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: :db.error/not-an-entity Unable to resolve entity: :a at datomic.promise$throw_executionexception_if_throwable.invokeStatic(promise.clj:10) at datomic.promise$throw_executionexception_if_throwable.invoke(promise.clj:6) at datomic.promise$settable_future$reify1048.deref(promise.clj:54) at clojure.core$deref.invokeStatic(core.clj:2310) at clojure.core$deref.invoke(core.clj:2296) at com.cognitect.vase.actions$apply_tx.invokeStatic(actions.clj:110) at com.cognitect.vase.actions$apply_tx.invoke(actions.clj:101) at vasetest.server$eval14784$fn14786.invoke(server.clj:40) at io.pedestal.interceptor.chain$try_f.invokeStatic(chain.clj:52) ... 39 common frames omitted Caused by: datomic.impl.Exceptions$IllegalArgumentExceptionInfo: :db.error/not-an-entity Unable to resolve entity: :a at datomic.error$arg.invokeStatic(error.clj:57) at datomic.error$arg.invoke(error.clj:52) at datomic.error$arg.invokeStatic(error.clj:55) at datomic.error$arg.invoke(error.clj:52) at datomic.db$require_id.invokeStatic(db.clj:588) at datomic.db$require_id.invokePrim(db.clj) at datomic.db$require_attrid.invokeStatic(db.clj:683) at datomic.db$require_attrid.invoke(db.clj:680) at datomic.db$expand_map$fn2568.invoke(db.clj:2409) at clojure.core.protocols$fn9143.invokeStatic(protocols.clj:167) at clojure.core.protocols$fn9143.invoke(protocols.clj:124) at clojure.core.protocols$fn9098$G9093__9107.invoke(protocols.clj:19) at clojure.core.protocols$seq_reduce.invokeStatic(protocols.clj:31) at clojure.core.protocols$fn9126.invokeStatic(protocols.clj:75) at clojure.core.protocols$fn9126.invoke(protocols.clj:75) at clojure.core.protocols$fn9072$G90679085.invoke(protocols.clj:13) at clojure.core$reduce.invokeStatic(core.clj:6704) at clojure.core$reduce.invoke(core.clj:6686) at datomic.db$expand_map.invokeStatic(db.clj:2404) at datomic.db$expand_map.invoke(db.clj:2398) at datomic.db.ProcessInpoint.inject(db.clj:2452) at datomic.db$with_tx$inject_all2660$fn2661.invoke(db.clj:2698) at clojure.lang.PersistentVector.reduce(PersistentVector.java:341) at clojure.core$reduce.invokeStatic(core.clj:6703) at clojure.core$reduce.invoke(core.clj:6686) at datomic.db$with_tx$inject_all2660.invoke(db.clj:2698) at datomic.db$with_tx.invokeStatic(db.clj:2702) at datomic.db$with_tx.invoke(db.clj:2691) at datomic.peer.LocalConnection$fn8221.invoke(peer.clj:564) at datomic.peer.LocalConnection.transactAsync(peer.clj:564) at datomic.peer.LocalConnection.transact(peer.clj:556) at datomic.api$transact.invokeStatic(api.clj:94) at datomic.api$transact.invoke(api.clj:92) at com.cognitect.vase.actions$apply_tx.invokeStatic(actions.clj:108) ... 42 common frames omitted INFO i.p.http.impl.servlet-interceptor - {:msg "sending error", :message "Internal server error: exception", :line 214}

mtnygard commented 7 years ago

I clarified in the doc that this was just an example of how to construct a payload and curl command.