From 5093819290f2ca0da03c1a20f5a093516c6f13f8 Mon Sep 17 00:00:00 2001 From: theburningmonk Date: Fri, 5 Jun 2020 23:43:09 +0200 Subject: [PATCH 1/2] fix: handle message attributes Closes #94 --- src/commands/replay-sqs-dlq.js | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/commands/replay-sqs-dlq.js b/src/commands/replay-sqs-dlq.js index a8879fa..63788d3 100644 --- a/src/commands/replay-sqs-dlq.js +++ b/src/commands/replay-sqs-dlq.js @@ -86,11 +86,25 @@ class ReplaySqsDlqCommand extends Command { const SQS = new AWS.SQS(); return async messages => { - const sendEntries = messages.map(msg => ({ - Id: msg.MessageId, - MessageBody: msg.Body, - MessageAttributes: msg.MessageAttributes - })); + const sendEntries = messages.map(msg => { + // as per #94, can't send message attributes where StringListValues is defined... + const msgAttrPairs = _.toPairs(msg.MessageAttributes); + const supportedAttrs = msgAttrPairs + // eslint-disable-next-line no-unused-vars + .filter(([key, value]) => value.DataType === "String") + .map(([key, { DataType, StringValue }]) => [ + key, + { DataType, StringValue } + ]); + const messageAttributes = _.fromPairs(supportedAttrs); + + return { + Id: msg.MessageId, + MessageBody: msg.Body, + MessageAttributes: messageAttributes + }; + }); + await SQS.sendMessageBatch({ QueueUrl: queueUrl, Entries: sendEntries From bc87e138e95110975eb46fa4f0809da75ddff010 Mon Sep 17 00:00:00 2001 From: theburningmonk Date: Fri, 5 Jun 2020 23:46:11 +0200 Subject: [PATCH 2/2] style: fixed prettier errors --- src/commands/replay-sqs-dlq.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commands/replay-sqs-dlq.js b/src/commands/replay-sqs-dlq.js index 63788d3..2e734d7 100644 --- a/src/commands/replay-sqs-dlq.js +++ b/src/commands/replay-sqs-dlq.js @@ -97,14 +97,14 @@ class ReplaySqsDlqCommand extends Command { { DataType, StringValue } ]); const messageAttributes = _.fromPairs(supportedAttrs); - + return { Id: msg.MessageId, MessageBody: msg.Body, MessageAttributes: messageAttributes }; }); - + await SQS.sendMessageBatch({ QueueUrl: queueUrl, Entries: sendEntries