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

ClassCastException during URI serialization #145

Closed
ghost opened this issue Jul 15, 2020 · 2 comments
Closed

ClassCastException during URI serialization #145

ghost opened this issue Jul 15, 2020 · 2 comments
Labels
bug Something isn't working

Comments

@ghost
Copy link

ghost commented Jul 15, 2020

Description

This exception was observed when using [com.cognitect.aws/kafka "801.2.686.0"] to make an {:op :DescribeConfigurationRevision} request:

   {:request
    (...
     {:op :DescribeConfigurationRevision,
      :request
      {:Arn
       "arn:aws:kafka:...",
       :Revision 1}}),
    :response
    {:cognitect.anomalies/category :cognitect.anomalies/fault,
     :cognitect.aws.client/throwable #error {
    :cause "class java.lang.Long cannot be cast to class java.lang.String (java.lang.Long and java.lang.String are in module java.base of loader 'bootstrap')"

At the line in question:

ecad8a3010bc6c4dd3ac3005b15c8a6020fbee2a

When the input-shape supplied to cognitect.aws.protocols.rest/serialize-uri has a member that has a :shape of type "__long", and a "uri" :location, the said exception is thrown:

user> (cognitect.aws.protocols.rest/serialize-uri "/v1/configurations/{arn}/revisions/{revision}" {:type "structure", :members {:Arn {:shape "__string", :location "uri", :locationName "arn"}, :Revision
{:shape "__long", :location "uri", :locationName "revision"}}, :required ["Revision" "Arn"]} {:arn "arn:aws:kafka:test:123456:configuration/test/123456", :revision 1})
Execution error (ClassCastException) at cognitect.aws.util/url-encode (util.clj:190).
class java.lang.Long cannot be cast to class java.lang.String (java.lang.Long and java.lang.String are in module java.base of loader 'bootstrap')

Solution

For each URI path value, covert the value to a string before encoding:

diff --git a/src/cognitect/aws/protocols/rest.clj b/src/cognitect/aws/protocols/rest.clj
--- a/src/cognitect/aws/protocols/rest.clj
+++ b/src/cognitect/aws/protocols/rest.clj
@@ -35,6 +35,7 @@
                                remove-leading-slash)
                        (some-> args
                                (get (keyword param))
+                               str
                                util/url-encode
                                remove-leading-slash))
@dchelimsky dchelimsky added the bug Something isn't working label Jul 17, 2020
@dchelimsky
Copy link
Contributor

8a0a3d3

This will be part of the next release, this week or next. Thanks!

@dchelimsky
Copy link
Contributor

Released today in version 0.8.620. 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

1 participant