Skip to content

AWS invalid signature when using an imported request body #919

@hhomar

Description

@hhomar

Hi

When using an imported request body with an AWS request, I get the following error:

{
  "__type": "com.amazon.coral.service#InvalidSignatureException",
  "message": "The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details...."
}

The request works fine using an inline request body. The difference being that the body is not passed to the AWS signer when using an imported request body:

Looking at the body sent in to the awsAuthVariableReplacer.

For the inline request it is (as expected):

"{\"queueUrl\":\"https://sqs.us-east-2.amazonaws.com/000000000000/queue\",\"message\":\"test\"}"

For the imported request, it is an array containing a buffer and an empty string:

[ Buffer<...>, ' ' ]

The awsAuthVariableReplacer only expects the body to be a Buffer or string:

body: Buffer.isBuffer(request.body) || utils.isString(request.body) ? request.body : undefined,

I used git bisect to trace the problem back to this commit: b754ab7.

I've got a branch to fix the issue, but I'm not sure if it's the best solution (hence no PR) as it will end up transforming the body twice:

hhomar@62771d1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions