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

[client-sqs] receiveMessage fails if message contains combination from decodeEscapedXML function #2375

Closed
trivikr opened this issue May 11, 2021 · 3 comments · Fixed by #2381
Labels
bug This issue is a bug.

Comments

@trivikr
Copy link
Member

trivikr commented May 11, 2021

Describe the bug

receiveMessage fails if message contains combination from decodeEscapedXML function:

const decodeEscapedXML = (str: string) =>
str
.replace(/&/g, "&")
.replace(/'/g, "'")
.replace(/"/g, '"')
.replace(/>/g, ">")
.replace(/&lt;/g, "<");

Your environment

SDK version number

@aws-sdk/client-sqs@3.14.0

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

All, tested in Node.js

Details of the browser/Node.js/ReactNative version

v14.16.1

Steps to reproduce

import { SQS } from "@aws-sdk/client-sqs";

const region = "us-west-2";
const client = new SQS({ region });

const messagesWithEscapeValues = ["&apos;", "&quot;", "&gt;", "&lt;"];

for (const MessageBody of messagesWithEscapeValues) {
  const QueueName = `test-${Date.now()}`;
  const { QueueUrl } = await client.createQueue({ QueueName });

  console.log(`MessageBody: "${MessageBody}"`);
  await client.sendMessage({
    MessageBody,
    QueueUrl,
  });

  try {
    await client.receiveMessage({ QueueUrl });
  } catch (error) {
    console.log(error);
  }
  await client.deleteQueue({ QueueUrl });
}

Observed behavior

MessageBody: "&apos;"
Error: Invalid MD5 checksum on messages: 8c12d8b6-bba2-4ff8-8fcf-919f6fb9be8f
    at /Users/trivikr/workspace/test/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 /Users/trivikr/workspace/test/node_modules/@aws-sdk/middleware-logger/dist/cjs/loggerMiddleware.js:6:22
    at async file:///Users/trivikr/workspace/test/sqs-escaped.mjs:19:5
MessageBody: "&quot;"
Error: Invalid MD5 checksum on messages: 83a7f240-70db-4ddf-b42e-e41953fbc4e8
    at /Users/trivikr/workspace/test/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 /Users/trivikr/workspace/test/node_modules/@aws-sdk/middleware-logger/dist/cjs/loggerMiddleware.js:6:22
    at async file:///Users/trivikr/workspace/test/sqs-escaped.mjs:19:5
MessageBody: "&gt;"
Error: Invalid MD5 checksum on messages: a911a9bb-8979-426a-97c6-1979de2d4819
    at /Users/trivikr/workspace/test/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 /Users/trivikr/workspace/test/node_modules/@aws-sdk/middleware-logger/dist/cjs/loggerMiddleware.js:6:22
    at async file:///Users/trivikr/workspace/test/sqs-escaped.mjs:19:5
MessageBody: "&lt;"
Error: Invalid MD5 checksum on messages: d170f6b0-4aee-4c4e-a1fe-f67118024cd9
    at /Users/trivikr/workspace/test/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 /Users/trivikr/workspace/test/node_modules/@aws-sdk/middleware-logger/dist/cjs/loggerMiddleware.js:6:22
    at async file:///Users/trivikr/workspace/test/sqs-escaped.mjs:19:5

Expected behavior

The SQS should receiveMessage when sentMessage contains any of the following character combinations:

["&apos;", "&quot;", "&gt;", "&lt;"]

Additional context

This issue was noticed while debugging #2362

@trivikr trivikr added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. and removed needs-triage This issue or PR still needs to be triaged. labels May 11, 2021
@trivikr
Copy link
Member Author

trivikr commented May 11, 2021

This issue happens as the code to decode escaped XML was added to fix #950

@trivikr
Copy link
Member Author

trivikr commented May 11, 2021

This seems to be an issue with upstream at NaturalIntelligence/fast-xml-parser#343

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant