Lambda invoke response is parsed to JSON automatically
itai-spiritt opened this issue · comments
Dependencies
com.cognitect.aws/api {:mvn/version "0.8.692"}
com.cognitect.aws/endpoints {:mvn/version "1.1.12.504"}
com.cognitect.aws/lambda {:mvn/version "848.2.1413.0"}
Description with failing test case
Executing a lambda for a datomic query (proxy) that the response is a vector results in an error.
(aws/invoke lambda {:op :InvokeWithResponseStream
:request {:FunctionName "datomic-query"
:Payload
(json/write-str {:query (str '[:find ?name :where [_ :app/name ?name]])})}})
Analyzing the response, you can see the request has succeeded.
My guess is that it fails parsing the vector response as a json?
(-> (aws/invoke lambda {:op :InvokeWithResponseStream
:request {:FunctionName "datomic query"
:Payload
(json/write-str {:query (str '[:find ?name :where [_ :app/name ?name]])})}})
meta
:http-response
:body
.readAllBytes
String.
)
; "���F���Z�s���:event-type��\fPayloadChunk\r:content-type���application/octet-stream\r:message-type���event[[\"app-1\"],[\"app-2\"],[\"test\"],[\"app-3\"],[\"another-test\"],[\"app-4\"]]�%�n���f���T�V�i�:event-type���InvokeComplete\r:content-type���application/json\r:message-type���event{}p��g"
Stack traces
{:cognitect.anomalies/category :cognitect.anomalies/fault, :cognitect.aws.client.impl/throwable #error {:cause "No matching clause: 0"
:via
[{:type java.lang.IllegalArgumentException
:message "No matching clause: 0"
:at [clojure.data.json$next_token invokeStatic "json.clj" 321]}]
:trace
[[clojure.data.json$next_token invokeStatic "json.clj" 321]
[clojure.data.json$next_token invoke "json.clj" 317]
[clojure.data.json$_read invokeStatic "json.clj" 406]
[clojure.data.json$_read invoke "json.clj" 404]
[clojure.data.json$_read1 invokeStatic "json.clj" 453]
[clojure.data.json$_read1 invoke "json.clj" 451]
[clojure.data.json$read_str invokeStatic "json.clj" 547]
[clojure.data.json$read_str doInvoke "json.clj" 539]
[clojure.lang.RestFn invoke "RestFn.java" 439]
[cognitect.aws.shape$json_parse invokeStatic "shape.clj" 152]
[cognitect.aws.shape$json_parse invoke "shape.clj" 149]
[cognitect.aws.protocols.rest$parse_body invokeStatic "rest.clj" 252]
[cognitect.aws.protocols.rest$parse_body invoke "rest.clj" 244]
[cognitect.aws.protocols.rest$parse_http_response invokeStatic "rest.clj" 265]
[cognitect.aws.protocols.rest$parse_http_response invoke "rest.clj" 258]
[cognitect.aws.protocols.rest_json$eval24310$fn__24311 invoke "rest_json.clj" 41]
[clojure.lang.MultiFn invoke "MultiFn.java" 239]
[cognitect.aws.client.impl$handle_http_response invokeStatic "impl.clj" 30]
[cognitect.aws.client.impl$handle_http_response invoke "impl.clj" 24]
[cognitect.aws.client.impl$send_request$fn__23586$state_machine__18197__auto____23615$fn__23618 invoke "impl.clj" 87]
[cognitect.aws.client.impl$send_request$fn__23586$state_machine__18197__auto____23615 invoke "impl.clj" 83]
[clojure.core.async.impl.ioc_macros$run_state_machine invokeStatic "ioc_macros.clj" 972]
[clojure.core.async.impl.ioc_macros$run_state_machine invoke "ioc_macros.clj" 971]
[clojure.core.async.impl.ioc_macros$run_state_machine_wrapped invokeStatic "ioc_macros.clj" 976]
[clojure.core.async.impl.ioc_macros$run_state_machine_wrapped invoke "ioc_macros.clj" 974]
[clojure.core.async.impl.ioc_macros$take_BANG_$fn__18215 invoke "ioc_macros.clj" 985]
[clojure.core.async.impl.channels.ManyToManyChannel$fn__12101$fn__12102 invoke "channels.clj" 100]
[clojure.lang.AFn run "AFn.java" 22]
[java.util.concurrent.ThreadPoolExecutor runWorker "ThreadPoolExecutor.java" 1144]
[java.util.concurrent.ThreadPoolExecutor$Worker run "ThreadPoolExecutor.java" 642]
[clojure.core.async.impl.concurrent$counted_thread_factory$reify__11970$fn__11971 invoke "concurrent.clj" 29]
[clojure.lang.AFn run "AFn.java" 22]
[java.lang.Thread run "Thread.java" 1589]]}}