diff --git a/packages/rocketchat-lib/server/methods/updateMessage.js b/packages/rocketchat-lib/server/methods/updateMessage.js index d55316ff4865..f279bb353d67 100644 --- a/packages/rocketchat-lib/server/methods/updateMessage.js +++ b/packages/rocketchat-lib/server/methods/updateMessage.js @@ -39,12 +39,11 @@ Meteor.methods({ } } - if (originalMessage.attachments) { - if (originalMessage.attachments[0].description !== undefined) { - message.attachments = originalMessage.attachments; - message.attachments[0].description = message.msg; - message.msg = originalMessage.msg; - } + // It is possible to have an empty array as the attachments property, so ensure both things exist + if (originalMessage.attachments && originalMessage.attachments.length > 0 && originalMessage.attachments[0].description !== undefined) { + message.attachments = originalMessage.attachments; + message.attachments[0].description = message.msg; + message.msg = originalMessage.msg; } message.u = originalMessage.u;