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

Unable to send JSON payload for SQS messages #75

Open
senior opened this issue Mar 30, 2020 · 1 comment
Open

Unable to send JSON payload for SQS messages #75

senior opened this issue Mar 30, 2020 · 1 comment
Labels

Comments

@senior
Copy link

senior commented Mar 30, 2020

I'm attempting to send an SQS message, where the payload is JSON data and it's failing. The specific error "AWS query cannot have multiple values for same key" (which appears to be from here).

With an invocation like

Aws_async.Runtime.run_request ~region ~access_key ~secret_key
    (module SendMessage)
   (Types.SendMessageRequest.make ~queue_url:(Uri.to_string queue_url) ~message_body:message ())

Where message is a JSON document in a string. To reproduce the issue, any JSON map with more than one keypair would work, so something like:

{"a": 1, "b": 2}

Doing some debugging, it looks like this code is where the request is getting broken:

(Uri.query_of_encoded
               (Query.render (SendMessageRequest.to_query req)))

It is using the Uri library to encode the message into a query string, which has some issues when encoding things for AWS (see mirage/ocaml-uri#65). What it looks like is happening here is that it's treating the commas as the query key having multiple values. That causes the "AWS query cannot have multiple values for the same key" error and also causes the JSON document to become invalid.

@tmcgilchrist
Copy link
Collaborator

Thanks for reporting the issue @senior!
It looks like that is a longstanding issue with the Uri library that needs to be fixed upstream, unfortunately I hadn't hit this earlier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants