aws

http://status.aws.amazon.com/ https://www.expeditedssl.com/aws-in-plain-english
kenny 2020-03-06T18:02:37.077800Z

Sometimes aws-api will return an anomaly with an incorrect category (e.g., incorrect or fault) when the actual category should be busy. This is on AWS for returning the wrong status code. We would, however, like to change the categories of these anomalies to the correct category. For example, the CloudWatch API will indicate a throttling error like so #(= "Throttling" (get-in % [:ErrorResponse :Error :Code])). Is there any thinking on the best way to do this? It would seem like the best way is to create our own invoke function and ensure every caller uses that instead of cognitect.aws.client.api/invoke.

jimmy 2020-03-06T18:50:41.080100Z

When trying to use s3 :SelectObjectContent I get an error about failing to parse xml

jimmy 2020-03-06T18:50:41.080200Z

(aws/invoke s3
            {:op :SelectObjectContent
             :request
             {:Bucket bucket
              :Key my-key
              :Expression "select * from S3Object s"
              :ExpressionType "SQL"
              :InputSerialization {:CSV {:RecordDelimiter "\r\n"}}
              :OutputSerialization {:JSON {:Type "LINES"}}}})

;; =>

{:cognitect.anomalies/category :cognitect.anomalies/fault,
 :cognitect.aws.client/throwable #error {
 :cause "ParseError at [row,col]:[1,1]\nMessage: Content is not allowed in prolog."
 :via
 [{:type javax.xml.stream.XMLStreamException
   :message "ParseError at [row,col]:[1,1]\nMessage: Content is not allowed in prolog."
   :at [<http://com.sun.org|com.sun.org>.apache.xerces.internal.impl.XMLStreamReaderImpl next "XMLStreamReaderImpl.java" 652]}]
 :trace
 [[<http://com.sun.org|com.sun.org>.apache.xerces.internal.impl.XMLStreamReaderImpl next "XMLStreamReaderImpl.java" 652]
  [clojure.data.xml.jvm.parse$pull_seq$fn__29940 invoke "parse.clj" 78]
  [clojure.lang.LazySeq sval "LazySeq.java" 42]
  [clojure.lang.LazySeq seq "LazySeq.java" 51]
  [clojure.lang.RT seq "RT.java" 535]
  [clojure.core$seq__5402 invokeStatic "core.clj" 137]
  [clojure.core$seq__5402 invoke "core.clj" 137]
  [clojure.data.xml.tree$seq_tree$fn__29773 invoke "tree.clj" 39]
  [clojure.lang.LazySeq sval "LazySeq.java" 42]
  [clojure.lang.LazySeq seq "LazySeq.java" 51]
  [clojure.lang.LazySeq first "LazySeq.java" 73]
  [clojure.lang.RT first "RT.java" 692]
  [clojure.core$first__5384 invokeStatic "core.clj" 55]
  [clojure.core$ffirst__5394 invokeStatic "core.clj" 103]
  [clojure.core$ffirst__5394 invoke "core.clj" 103]
  [clojure.data.xml.tree$event_tree invokeStatic "tree.clj" 70]
  [clojure.data.xml.tree$event_tree invoke "tree.clj" 66]
  [clojure.data.xml$parse invokeStatic "xml.clj" 109]
  [clojure.data.xml$parse doInvoke "xml.clj" 84]
  [clojure.lang.RestFn invoke "RestFn.java" 486]
  [cognitect.aws.util$xml_read invokeStatic "util.clj" 148]
  [cognitect.aws.util$xml_read invoke "util.clj" 145]
  [cognitect.aws.shape$xml_parse invokeStatic "shape.clj" 217]
  [cognitect.aws.shape$xml_parse invoke "shape.clj" 214]
  [cognitect.aws.protocols.rest$parse_body invokeStatic "rest.clj" 243]
  [cognitect.aws.protocols.rest$parse_body invoke "rest.clj" 235]
  [cognitect.aws.protocols.rest$parse_http_response invokeStatic "rest.clj" 260]
  [cognitect.aws.protocols.rest$parse_http_response invoke "rest.clj" 249]
  [cognitect.aws.protocols.rest_xml$eval32111$fn__32112 invoke "rest_xml.clj" 23]
  [clojure.lang.MultiFn invoke "MultiFn.java" 239]
  [cognitect.aws.client$handle_http_response invokeStatic "client.clj" 49]
  [cognitect.aws.client$handle_http_response invoke "client.clj" 44]
  [cognitect.aws.client$send_request$fn__31513$state_machine__20194__auto____31540$fn__31543 invoke "client.clj" 112]
  [cognitect.aws.client$send_request$fn__31513$state_machine__20194__auto____31540 invoke "client.clj" 108]
  [clojure.core.async.impl.ioc_macros$run_state_machine invokeStatic "ioc_macros.clj" 973]
  [clojure.core.async.impl.ioc_macros$run_state_machine invoke "ioc_macros.clj" 972]
  [clojure.core.async.impl.ioc_macros$run_state_machine_wrapped invokeStatic "ioc_macros.clj" 977]
  [clojure.core.async.impl.ioc_macros$run_state_machine_wrapped invoke "ioc_macros.clj" 975]
  [clojure.core.async.impl.ioc_macros$take_BANG_$fn__20212 invoke "ioc_macros.clj" 986]
  [clojure.core.async.impl.channels.ManyToManyChannel$fn__15077$fn__15078 invoke "channels.clj" 95]
  [clojure.lang.AFn run "AFn.java" 22]
  [java.util.concurrent.ThreadPoolExecutor runWorker "ThreadPoolExecutor.java" 1128]
  [java.util.concurrent.ThreadPoolExecutor$Worker run "ThreadPoolExecutor.java" 628]
  [clojure.core.async.impl.concurrent$counted_thread_factory$reify__14946$fn__14947 invoke "concurrent.clj" 29]
  [clojure.lang.AFn run "AFn.java" 22]
  [java.lang.Thread run "Thread.java" 830]]}}

jimmy 2020-03-06T18:50:41.080300Z

I'm guessing that because the aws-api is generic it assuming this endpoint returns xml when it does not. Is there anyway to make it not try to parse the body as xml?

ghadi 2020-03-06T18:51:36.080900Z

@jimmy capture the (meta response)

ghadi 2020-03-06T18:51:44.081200Z

should have a response body that might be helpful

ghadi 2020-03-06T18:52:12.081500Z

(but obviously it's CSV)

ghadi 2020-03-06T18:53:03.082400Z

can you file an issue? In the meantime, maybe try re-reading the response inputstream body correctly in userspace

ghadi 2020-03-06T18:53:12.082600Z

as a workaround

jimmy 2020-03-06T18:53:40.083400Z

Thanks for the work around. I will definitely file an issue about it

jimmy 2020-03-06T18:53:53.083800Z

Any info you want me to capture other than what I've provided?

ghadi 2020-03-06T18:53:55.083900Z

@kenny same request for you -- is "Throttling" represented as an http status code, or only within [:ErrorResponse :Error :Code]) ?

ghadi 2020-03-06T18:54:27.084600Z

@jimmy any setup code necessary to make an object that is readable in this way

👍 1
2020-03-06T18:54:40.085100Z

Before you file an issue - please check your dependencies.

ghadi 2020-03-06T18:55:23.086300Z

this one isn't probably our favorite data.xml dep issue --

2020-03-06T18:55:33.086600Z

no?

ghadi 2020-03-06T18:55:36.086800Z

but knowing the deps will be useful

ghadi 2020-03-06T18:55:53.087200Z

no, he's asking for a special response handling from S3:

:InputSerialization {:CSV {:RecordDelimiter "\r\n"}}
              :OutputSerialization {:JSON {:Type "LINES"}}}})

ghadi 2020-03-06T18:56:08.087800Z

dunno if that conflicts with the client's reading of the service descriptor

2020-03-06T18:58:36.088Z

It does

2020-03-06T18:59:05.088200Z

ghadi 2020-03-06T18:59:19.089400Z

looks like this is a Two-fer Tuesday

1
🙃 1
2020-03-06T19:00:18.090300Z

Type is not part of the JSON map under OutputSerialization

jimmy 2020-03-06T19:02:25.090800Z

True, but changing that does not make a difference.

2020-03-06T19:03:04.091400Z

Are you using lein or tools.deps or other?

jimmy 2020-03-06T19:03:10.091600Z

tools.deps

2020-03-06T19:03:57.092200Z

what version clojure/data.xml is in clj -Spath

2020-03-06T19:07:07.092900Z

OK - never mind. I see I'm barking up the wrong tree.

jimmy 2020-03-06T19:09:13.094400Z

It is 0.2.0-alpha6. But yeah, if you look at the response body it isn't just straight forward xml. I'll file an issue that given a bucket you should be able to test it and recreate it. Sadly the body is complicated enough, probably not worth me trying to do the work around right now.

ghadi 2020-03-06T19:09:47.094700Z

the response format is..... artisanal

😂 1
2020-03-06T19:10:46.094900Z

Or custom, in which case you could customize it. But how do you artisanize it?

ghadi 2020-03-06T19:11:51.095400Z

:eventstream true

ghadi 2020-03-06T19:12:02.095600Z

fun

jimmy 2020-03-06T19:20:41.096200Z

Made the issue https://github.com/cognitect-labs/aws-api/issues/132 Thanks for the help @ghadi

👍 2