Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when date format is Double #36

Closed
royipressburger opened this issue Jan 14, 2019 · 6 comments
Closed

Crash when date format is Double #36

royipressburger opened this issue Jan 14, 2019 · 6 comments
Labels
bug Something isn't working

Comments

@royipressburger
Copy link

Hi all.

Im working with this lib for cognito-idp and I have encountered an exception when parsing the aws response:

java.lang.Double cannot be cast to java.lang.CharSequence
        [clojure.core$re_matcher invokeStatic "core.clj" 4849]
        [clojure.core$re_matches invokeStatic "core.clj" 4886]
        [clojure.core$re_matches invoke "core.clj" 4886]
        [cognitect.aws.shape$parse_date invokeStatic "shape.clj" 86]
        [cognitect.aws.shape$parse_date invoke "shape.clj" 79]
        [cognitect.aws.shape$eval26825$fn__26826 invoke "shape.clj" 150]
        [clojure.lang.MultiFn invoke "MultiFn.java" 234]

After some debugging I saw that the response of the aws request looks like this:

;;Requesting a list group of a user pool, This throws the error above
(aws/invoke cognito {:op :ListGroups :request {:UserPoolId "my-user-pool-id"}})

;; Added this for debugging
(def http-meta (slurp (:body (:http-response (meta (aws/invoke cognito {:op :ListGroups :request {:UserPoolId "my-user-pool-id"}}))))))

(def response (json/parse-string http-meta true))

;; the response looks like: 
{:Groups
 [{:CreationDate 1.547453349895E9,
   :Description "My App",
   :GroupName "Group 1",
   :LastModifiedDate 1.547453349895E9,
   :UserPoolId "my-user-pool-id"}]}

As you can see the format of CreationDate and LastModifiedDate is double
this causes to crash in the shape/parse-data.
adding a (double? data) (java.util.Date. (* 1000 (long data))) is fixing the issue

if more info is needed let me know,
Thanks ahead

@dchelimsky dchelimsky added the bug Something isn't working label Jan 14, 2019
@dchelimsky
Copy link
Contributor

Would you please post the raw string? e.g. (slurp (:body (:http-response (meta (aws/invoke cognito {:op :ListGroups :request {:UserPoolId "my-user-pool-id"}})))))

@dchelimsky
Copy link
Contributor

Never mind. I've got an example working.

@dchelimsky
Copy link
Contributor

Fix is on master, so it'll be part of the next release.

@royipressburger
Copy link
Author

Thanks for the fast fix!

@dchelimsky
Copy link
Contributor

You made it kind of easy ;)

@dchelimsky
Copy link
Contributor

Released in 0.8.204.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants