Cloudron makes it easy to run web apps like WordPress, Nextcloud, GitLab on your server. Find out more or install now.


Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Bookmarks
  • Search
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

Cloudron Forum

Apps - Status | Demo | Docs | Install
  1. Cloudron Forum
  2. Mastodon
  3. Error while update to Mastodon 4.3

Error while update to Mastodon 4.3

Scheduled Pinned Locked Moved Solved Mastodon
10 Posts 2 Posters 2.9k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • itbeardI Offline
    itbeardI Offline
    itbeard
    wrote on last edited by
    #1

    Hey folks,
    After updating I was permanently getting errors of migration like on the screenshot below:
    3b2dd860-4e74-4762-b623-a7d5a14fe741-image.png

    In the end, I just restored the backup.
    Any ideas on how to fix it?

    1 Reply Last reply
    0
    • nebulonN Offline
      nebulonN Offline
      nebulon
      Staff
      wrote on last edited by
      #2

      The OTP_SECRET is set during first installation in /app/data/env.production https://git.cloudron.io/cloudron/mastodon-app/-/blob/master/start.sh?ref_type=heads#L65

      Is this correctly set in your backup or was it changed manually? I guess it is only relevant also if any user uses 2fa already and does it work before the update?

      itbeardI 1 Reply Last reply
      0
      • nebulonN nebulon

        The OTP_SECRET is set during first installation in /app/data/env.production https://git.cloudron.io/cloudron/mastodon-app/-/blob/master/start.sh?ref_type=heads#L65

        Is this correctly set in your backup or was it changed manually? I guess it is only relevant also if any user uses 2fa already and does it work before the update?

        itbeardI Offline
        itbeardI Offline
        itbeard
        wrote on last edited by
        #3

        @nebulon Hello,
        OTP_SECRET was set two years ago and has not changed since then. Some users successfully use 2FA (including me)

        1 Reply Last reply
        0
        • nebulonN Offline
          nebulonN Offline
          nebulon
          Staff
          wrote on last edited by
          #4

          and if you update the app (maybe into a clone), does that OTP_SECRET change? If so this may be a packaging bug we then have to investigate. Otherwise this seems like an upstream mastodon issue, maybe wrongly reporting

          1 Reply Last reply
          0
          • itbeardI Offline
            itbeardI Offline
            itbeard
            wrote on last edited by
            #5

            I checked the OTP_SECRET value - it is the same before and after the update. Still the same error:

            Oct 22 00:56:25 ==> Configuring mastodon
            Oct 22 00:56:25 ==> Migrating database
            Oct 22 00:56:25 ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY=*************
            Oct 22 00:56:25 ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT=************
            Oct 22 00:56:25 ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY=**************
            Oct 22 00:56:28 I, [2024-10-21T22:56:28.524715 #15] INFO -- : [dotenv] Loaded .env.production
            Oct 22 00:56:29 2024-10-21T22:56:29.000Z
            Oct 22 00:56:29 2024-10-21T22:56:29.000Z
            Oct 22 00:56:29 2024-10-21T22:56:29.000Z
            Oct 22 00:56:29 2024-10-21T22:56:29.000Z
            Oct 22 00:56:29 2024-10-21T22:56:29.000Z
            Oct 22 00:56:29 == 20240307180905 MigrateDeviseTwoFactorSecrets: migrating ====================
            Oct 22 00:56:29 ERROR: Unable to decrypt OTP secret for user 1.
            Oct 22 00:56:29 I, [2024-10-21T22:56:29.274159 #15] INFO -- : Migrating to MigrateDeviseTwoFactorSecrets (20240307180905)
            Oct 22 00:56:29 In this case, their OTP secret had already been lost with the change to `OTP_SECRET`, and
            Oct 22 00:56:29 Migration aborted.
            Oct 22 00:56:29 Please double-check that you have not accidentally changed `OTP_SECRET` just for this
            Oct 22 00:56:29 This is most likely because you have changed the value of `OTP_SECRET` at some point in
            Oct 22 00:56:29 migration, and re-run the migration with `MIGRATION_IGNORE_INVALID_OTP_SECRET=true`.
            Oct 22 00:56:29 proceeding with this migration will not make the situation worse.
            Oct 22 00:56:29 time after the user configured 2FA.
            
            1 Reply Last reply
            0
            • nebulonN nebulon referenced this topic on
            • nebulonN Offline
              nebulonN Offline
              nebulon
              Staff
              wrote on last edited by
              #6

              This is coming from https://github.com/mastodon/mastodon/blob/bb0532530666d877cae6345ce6a11c041b01fc7b/db/post_migrate/20240307180905_migrate_devise_two_factor_secrets.rb

              So this tries to migrate from the global OTP_SECRET to a user based one. Anyways since the value as such didn't change, this just reveals an issue which was already there.

              @itbeard can you try to put the app in recovery mode then open a webterminal into the app and run:

              MIGRATION_IGNORE_INVALID_OTP_SECRET=true /app/pkg/start.sh
              
              itbeardI 1 Reply Last reply
              1
              • nebulonN nebulon marked this topic as a question on
              • nebulonN nebulon

                This is coming from https://github.com/mastodon/mastodon/blob/bb0532530666d877cae6345ce6a11c041b01fc7b/db/post_migrate/20240307180905_migrate_devise_two_factor_secrets.rb

                So this tries to migrate from the global OTP_SECRET to a user based one. Anyways since the value as such didn't change, this just reveals an issue which was already there.

                @itbeard can you try to put the app in recovery mode then open a webterminal into the app and run:

                MIGRATION_IGNORE_INVALID_OTP_SECRET=true /app/pkg/start.sh
                
                itbeardI Offline
                itbeardI Offline
                itbeard
                wrote on last edited by
                #7

                @nebulon Thanks, all done!
                Your solution with MIGRATION_IGNORE_INVALID_OTP_SECRET=true /app/pkg/start.sh works perfectly.

                Steps:

                • Update to 4.3.0 (don’t forget to enable back up!)
                • Enable Recovery Mode in Cauldron's app admin panel
                • Run the command above (as suggested by @nebulon)
                • Disable Recovery Mode.

                2FA also works after migration; I tested it on several older accounts.
                Thanks a lot!

                1 Reply Last reply
                2
                • nebulonN Offline
                  nebulonN Offline
                  nebulon
                  Staff
                  wrote on last edited by
                  #8

                  Thanks for letting us know. I wonder if this came from some very old Mastodon installation, where the OTP_SECRET variable was not yet set in our package?

                  itbeardI 1 Reply Last reply
                  1
                  • nebulonN nebulon

                    Thanks for letting us know. I wonder if this came from some very old Mastodon installation, where the OTP_SECRET variable was not yet set in our package?

                    itbeardI Offline
                    itbeardI Offline
                    itbeard
                    wrote on last edited by
                    #9

                    @nebulon I definitely did not set it manually.

                    1 Reply Last reply
                    0
                    • nebulonN nebulon has marked this topic as solved on
                    • nebulonN Offline
                      nebulonN Offline
                      nebulon
                      Staff
                      wrote on last edited by
                      #10

                      right I meant more like the app was maybe installed from a package, where the OTP_SECRET was not yet set properly. This was then a packaging bug not a user error.

                      1 Reply Last reply
                      1

                      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                      With your input, this post could be even better 💗

                      Register Login
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Bookmarks
                      • Search