Messages with Images/Files prior to the update lost the text/comments

What version are you coming from?

Rocket.Chat 7.11.4

Bitnami MongoDB 5.0

What version are you going to?

Rocket.Chat 8.4.1

MongoDB 8.2.7 wiredTiger

What deployment method did you use to deploy?

Docker compose

Did you follow a particular doc? Which one?

Mongodb:

What issues are you running into upgrading?

After the upgrade messages with attachments, like images, lost the comment/text to the file.

The text of older comments are used for the images alt attribute instead of a seperate textelement.

Newly added messages with images and comment/text are displayed normaly.

Tested on Rocket.Chat Electron and multiple browsers with disabled caching.

Restore your backup. You can’t do these huge version jumps and expect it to work.

Before starting again I’d make sure you have stopped using GridFS and all your files/images are in local storage.

You need to migrate mongo one version at a time. 5 → 6 → 7-> 8

Check each works.

(You should have been on Mongo 7.x a long time ago)

Check the Mongo “featurecompatibility” setting mentioned multiple times.

Then finally upgrade Rocket, and personally, as per their docs, I’d do it a version at a time eg 7.11.x → 7.12.x etc as their upgrade Q&A is pants.

Unfortunately, I cannot restore the backup without losing six hours’ worth of messages. The issue unfortunately went unnoticed during testing, and everything else works flawlessly.

The MongoDB upgrade was performed using dump/restore, which completed successfully. Therefore, it should hopfully not be related to this process.

Regrettably, I trusted the guideline stating that only major releases must not be skipped. Is there a way to run the migration scripts for the minor versions afterward? Alternatively, would it be advisable or even possible, without restoring a backup, to downgrade to version 7.11.4 and then sequentially upgrade through each minor version?

Btw. Thanks for the GridFS hint. Will rocket.chat automatically migrate the files to the filesystem or do i have to use a script like this one (last update a year ago - GitHub - arminfelder/gridfsmigrate: RocketChat GridFS to filesytem migration script · GitHub)?

Oh :frowning:

Most likely it is to do with Mongo somewhere - that’s where all your info is stored…

I think you missed this… (I wrote quite a bit of it years ago)

Avoid skipping versions

Not as far as I know - they should run each update but the Q&A is pants and I would not trust them to all run correctly over such huge changes., as per the above migration strategy.

Absolutely not. You will likely compound your problems - you can’t safely downgrade at all due to the way Rocket modifies the DB.

As I said originally, restore from backup and incremental upgrades and full testing is the correct way to avoid issues.

It’s been standard practice for as long as I have used Rocket - about v0.16 IIRC…

No.

Yes.

Avoid skipping versions

Sorry, I missed this part. I just looked at the example, which only lists the major versions.

Since this appears to be the only issue, I will attempt to fix it directly in MongoDB and hope that no further errors arise. Going forward, I will always upgrade through each version sequentially.

Thank you very much for your quick support.

NP.

Might not be all you want to hear… But don’t shoot the messenger - I don’t work here!!

Quick update for everyone facing the same problem. The following process updates all messages with an attachment, where the attachment has a description, but the messagebody itself is empty.

  1. Check if you are getting a result with following command
db.rocketchat_message.find({msg: "", "attachments.0.description": {$exists: true, $ne: ""}}).limit(10).pretty()

If not, stop right here, you have another issue :smiley:

  1. Run this command for a specific message, knowing there should be a description for the image, to test if everything works like attempted.
    Replace the _id in the command .
    You can find the id with the browser-devtools (see image below)
db.rocketchat_message.updateOne({_id: "ENTER_YOUR_ID_HERE", msg: "", "attachments.0.description": {$exists: true, $ne: ""}},
  [
    {
      $set: {
        msg: {
          $getField: {
            field: "description",
            input: { $arrayElemAt: ["$attachments", 0] }
          }
        },
        md: {
          $getField: {
            field: "descriptionMd",
            input: { $arrayElemAt: ["$attachments", 0] }
          }
        }
      }
    }
  ])

  1. If everthing worked so far, let’s update all other messages
  db.rocketchat_message.updateMany({msg: "", "attachments.0.description": {$exists: true, $ne: ""}},
  [
    {
      $set: {
        msg: {
          $getField: {
            field: "description",
            input: { $arrayElemAt: ["$attachments", 0] }
          }
        },
        md: {
          $getField: {
            field: "descriptionMd",
            input: { $arrayElemAt: ["$attachments", 0] }
          }
        }
      }
    }
  ])
1 Like

Can you open an issue for this & post a link here please?

I can push the team to take a look as something has got missed.

I have asked that this be looked at but zero guarantee on time scale.

Probably this: