Fork me on GitHub

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

Jimmy Miller18:03:41

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

Jimmy Miller18:03:41

(aws/invoke s3
            {:op :SelectObjectContent
             {: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, #error {
 :cause "ParseError at [row,col]:[1,1]\nMessage: Content is not allowed in prolog."
   :message "ParseError at [row,col]:[1,1]\nMessage: Content is not allowed in prolog."
   :at [.apache.xerces.internal.impl.XMLStreamReaderImpl next "" 652]}]
 [[.apache.xerces.internal.impl.XMLStreamReaderImpl next "" 652]
  [$pull_seq$fn__29940 invoke "parse.clj" 78]
  [clojure.lang.LazySeq sval "" 42]
  [clojure.lang.LazySeq seq "" 51]
  [clojure.lang.RT seq "" 535]
  [clojure.core$seq__5402 invokeStatic "core.clj" 137]
  [clojure.core$seq__5402 invoke "core.clj" 137]
  [$seq_tree$fn__29773 invoke "tree.clj" 39]
  [clojure.lang.LazySeq sval "" 42]
  [clojure.lang.LazySeq seq "" 51]
  [clojure.lang.LazySeq first "" 73]
  [clojure.lang.RT first "" 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]
  [$event_tree invokeStatic "tree.clj" 70]
  [$event_tree invoke "tree.clj" 66]
  [$parse invokeStatic "xml.clj" 109]
  [$parse doInvoke "xml.clj" 84]
  [clojure.lang.RestFn invoke "" 486]
  [$xml_read invokeStatic "util.clj" 148]
  [$xml_read invoke "util.clj" 145]
  [$xml_parse invokeStatic "shape.clj" 217]
  [$xml_parse invoke "shape.clj" 214]
  [$parse_body invokeStatic "rest.clj" 243]
  [$parse_body invoke "rest.clj" 235]
  [$parse_http_response invokeStatic "rest.clj" 260]
  [$parse_http_response invoke "rest.clj" 249]
  [$eval32111$fn__32112 invoke "rest_xml.clj" 23]
  [clojure.lang.MultiFn invoke "" 239]
  [$handle_http_response invokeStatic "client.clj" 49]
  [$handle_http_response invoke "client.clj" 44]
  [$send_request$fn__31513$state_machine__20194__auto____31540$fn__31543 invoke "client.clj" 112]
  [$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 "" 22]
  [java.util.concurrent.ThreadPoolExecutor runWorker "" 1128]
  [java.util.concurrent.ThreadPoolExecutor$Worker run "" 628]
  [clojure.core.async.impl.concurrent$counted_thread_factory$reify__14946$fn__14947 invoke "concurrent.clj" 29]
  [clojure.lang.AFn run "" 22]
  [java.lang.Thread run "" 830]]}}

Jimmy Miller18:03:41

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?


@jimmy capture the (meta response)


should have a response body that might be helpful


(but obviously it's CSV)


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


as a workaround

Jimmy Miller18:03:40

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

Jimmy Miller18:03:53

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


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


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

👍 4

Before you file an issue - please check your dependencies.


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


but knowing the deps will be useful


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

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


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


looks like this is a Two-fer Tuesday

rich 4
🙃 4

Type is not part of the JSON map under OutputSerialization

Jimmy Miller19:03:25

True, but changing that does not make a difference.


Are you using lein or tools.deps or other?


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


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

Jimmy Miller19:03:13

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.


the response format is..... artisanal

😂 4

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


:eventstream true