Skip to content

SQS receiveMessage not handling new lines correctly #1893

@pkmnfrk

Description

@pkmnfrk

Describe the bug
The SQS client seems to mishandle the first(?) new line in a message body, turning it from \n into a space. This causes the MD5 hash validation to fail and the receiveMessages call to throw.

Error: Invalid MD5 checksum on messages: 12fcd5a6-338f-485a-9b01-949ad118a6f0
    at /home/mike/code/project/service/node_modules/@aws-sdk/middleware-sdk-sqs/dist/cjs/receive-message.js:21:19
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async /home/mike/code/project/service/node_modules/@aws-sdk/middleware-logger/dist/cjs/loggerMiddleware.js:7:22

SDK version number
@aws-sdk/client-sqs@1.0.0-rc.10
Reproduced in @aws-sdk/client-sqs@3.2.0

Is the issue in the browser/Node.js/ReactNative?
Node.js

Details of the browser/Node.js/ReactNative version
v14.8.0

To Reproduce (observed behavior)
Send a message to an SQS queue with a new line in it. Eg:

{
    "hello": "world"
}

Then, receive that message in the code:

const AWS = require("@aws-sdk/client-sqs");
const sqs = new AWS.SQS();
sqs
  .receiveMessage({
    QueueUrl: "https://sqs.us-east-1.amazonaws.com/...",
    WaitTimeSeconds: 20,
  })
  .then((data) => {
    console.log("Got", data.length, "messages");
  })
  .catch((e) => {
    console.error(e);
  });

Expected behavior
The call succeeds, and gives us the message.

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions