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

AWS invoke API ops giving java.lang.Character cannot be cast to java.lang.Number Error #71

Closed
gzmask opened this issue Apr 18, 2019 · 9 comments
Labels
bug Something isn't working

Comments

@gzmask
Copy link

gzmask commented Apr 18, 2019

This PR should fix it: #70

Error example in DynamoDB calls (other APIs have the same issue):

(def ddb
  (aws/client
    {:api :dynamodb
     :credentials-provider (credentials/basic-credentials-provider ...)}))

(aws/invoke ddb {:op :ListTables})

Stacktrace:
[[clojure.lang.RT uncheckedByteCast "RT.java" 1379]
[cognitect.aws.signers$uri_encode invokeStatic "signers.clj" 30]
[cognitect.aws.signers$uri_encode doInvoke "signers.clj" 15]
[clojure.lang.RestFn invoke "RestFn.java" 423]
[cognitect.aws.signers$canonical_uri invokeStatic "signers.clj" 59]
[cognitect.aws.signers$canonical_uri invoke "signers.clj" 51]
[cognitect.aws.signers$canonical_request invokeStatic "signers.clj" 106]
[cognitect.aws.signers$canonical_request invoke "signers.clj" 103]
[cognitect.aws.signers$string_to_sign invokeStatic "signers.clj" 115]
[cognitect.aws.signers$string_to_sign invoke "signers.clj" 113]
[cognitect.aws.signers$signature invokeStatic "signers.clj" 135]
[cognitect.aws.signers$signature invoke "signers.clj" 131]
[cognitect.aws.signers$v4_sign_http_request invokeStatic "signers.clj" 157]
[cognitect.aws.signers$v4_sign_http_request doInvoke "signers.clj" 137]
[clojure.lang.RestFn invoke "RestFn.java" 470]
[cognitect.aws.signers$eval36549$fn__36550 invoke "signers.clj" 161]
[clojure.lang.MultiFn invoke "MultiFn.java" 244]
[cognitect.aws.client$send_request invokeStatic "client.clj" 69]
[cognitect.aws.client$send_request invoke "client.clj" 63]
[cognitect.aws.client.api.async$invoke$send__36444 invoke "async.clj" 67]
[cognitect.aws.retry$with_retry$fn__36062$state_machine__23274__auto____36071$fn__36073 invoke "retry.clj" 15]
[cognitect.aws.retry$with_retry$fn__36062$state_machine__23274__auto____36071 invoke "retry.clj" 15]
[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]
[cognitect.aws.retry$with_retry$fn__36062 invoke "retry.clj" 15]
[clojure.lang.AFn run "AFn.java" 22]
[java.util.concurrent.ThreadPoolExecutor runWorker "ThreadPoolExecutor.java" 1149]
[java.util.concurrent.ThreadPoolExecutor$Worker run "ThreadPoolExecutor.java" 624]
[java.lang.Thread run "Thread.java" 748]]

@gzmask gzmask changed the title DynamoDB ops giving java.lang.Character cannot be cast to java.lang.Number Error AWS invoke API ops giving java.lang.Character cannot be cast to java.lang.Number Error Apr 18, 2019
@dchelimsky
Copy link
Contributor

I don't see this issue. What versions of cognitect.aws/api, cognitect.aws/endpoints, and cognitect.aws/dynamodb are you using?

@gzmask
Copy link
Author

gzmask commented Apr 19, 2019

All with newest version. Did your test exercise the uri-encode function? https://github.com/cognitect-labs/aws-api/blob/master/src/cognitect/aws/signers.clj#L15
It's a simple type mismatched error on the (byte \A) bits.

@dchelimsky
Copy link
Contributor

There are already numerous tests that exercise this function indirectly in https://github.com/cognitect-labs/aws-api/blob/master/test/src/cognitect/aws/signer_test.clj. Here's a direct unit test of the fn:

(require '[cognitect.aws.signers :as signers])
(require '[clojure.spec.test.alpha :as stest])

(s/fdef signers/uri-encode
  :args (s/cat :string (s/and string? not-empty) :extra-chars string?)
  :ret string?)

(stest/check `signers/uri-encode))

This produces this outcome:

({:spec
  #object[clojure.spec.alpha$fspec_impl$reify__2524 0x32c975de "clojure.spec.alpha$fspec_impl$reify__2524@32c975de"],
  :clojure.spec.test.check/ret
  {:result true, :num-tests 1000, :seed 1555691156677},
  :sym cognitect.aws.signers/uri-encode})

Please show me a failing test case I can execute.

@gzmask
Copy link
Author

gzmask commented Apr 19, 2019

Hmmm, I tested this with (set! *unchecked-math* true) and (set! *unchecked-math* false), the latter passes while the first one failed. So this is an issue with the byte function in core really 🤔

@dchelimsky
Copy link
Contributor

I ran the generative test above with both (set! *unchecked-math* true) and (set! *unchecked-math* false) and it keeps passing for me.

@dchelimsky
Copy link
Contributor

I'm closing this as I'm not able to reproduce this. If you can provide a failing test case (i.e. code that I can paste into a REPL and execute and see fail) I'll be glad to take another look and reopen this if appropriate.

@gzmask
Copy link
Author

gzmask commented Apr 19, 2019

uncheck-math is hard to test due to run time characteristics. You need to re-eval the defn to see the change in effect.

Try this:

(set! *unchecked-math* true)
(byte \A) ;; will fail
(set! *unchecked-math* false)
(byte \A) ;; will pass

@dchelimsky
Copy link
Contributor

Ah, tricky. I now see the failure. Fix coming soon.

@dchelimsky
Copy link
Contributor

dchelimsky commented Apr 19, 2019

Ended up a/ w faster implementation, too. Thanks!

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