Skip to content

Unable to send JSON payload for SQS messages #75

@senior

Description

@senior

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions