Can't upload images, can't upgrade Mattermost

Hi there,
We are on version 5.2.2 of Mattermost. I can see there are newer versions out there but don’t know how to upgrade the app.
We cannot upload images at all - not profile pictures, or images into chats.
Can you help?
Thanks,
Lucy

We are all on Macs - and only 5.2.2 is available in the Apple Store

Hi @lucyclhill ,

I think we found out that this is not related to the desktop app you’re using, but seems to be on the server side, right? If you can reproduce it on the webapp, we do not need to look further on the app side.
The most recent version is 5.2.2 and this one is also available in the appstore. The next release (5.3.0) is being prepared and once released, the application will automatically update to the new version.

Old post was removed. I have same problem. After update to 7.10.5 (im SQL i see 105 version) we have problem with upload files to chat. We have next error on respons in browser ( Request URL:

https://xxx.xx/api/v4/files/7dkmbunc5jdqxdw8zxcy45hmce/thumbnail):

  1. {id: “app.file_info.get.app_error”, message: “Failed to get file information.”,…}
  2. detailed_error: “failed to get FileInfo with id=7dkmbunc5jdqxdw8zxcy45hmce: Error 1054 (42S22): Unknown column ‘FileInfo.Archived’ in ‘field list’”
  3. id: “app.file_info.get.app_error”
  4. message: “Failed to get file information.”
  5. request_id: “nwtutre9otnyxqh8fqoai7ex7w”
  6. status_code: 500

What should we do?
Thanks in advance for your reply.

Hi @PavelSaik and welcome to the Mattermost forums!

Can you please verify your Mattermost version? There is no 7.10.5 release as of yet, but SQL version 105 sounds good.
What SQL server are you using? MySQL or PostgreSQL?
Can you please post the output of the following queries:

-- MySQL
use mattermost
show create table FileInfo;

-- PostgreSQL
\connect mattermost
\d fileinfo

Summary
Since version 7.0.2 any file uploads do not show for the other user, just get a big blank box after the text .

Steps to reproduce
create a message and attach a file or image and post

Expected behavior
other user should see the file to open or download

Observed behavior
other users never see the file

{“level”:“debug”,“msg”:“Received HTTP request”,“fields”:{“method”:“POST”,“request_id”:“4i6wgmjhc7g5j8nqsio5dtsbxy”,“status_code”:“200”,“url”:“/api/v4/channels/members/me/view”}}
{“level”:“debug”,“msg”:“Scheduling Job”,“fields”:{“scheduler”:“migrations”}}
{“level”:“debug”,“msg”:“All migrations are complete.”,“fields”:{“scheduler”:“migrations”}}
{“level”:“debug”,“msg”:“Next run time for scheduler”,“fields”:{“next_runtime”:“"\u003cnil\u003e"”,“scheduler_name”:“migrations”}}
{“level”:“debug”,“msg”:“Received HTTP request”,“fields”:{“method”:“POST”,“request_id”:“6twozcj5ijnbjf37zfoqrz3awo”,“status_code”:“200”,“url”:“/api/v4/channels/members/me/view”}}
{“level”:“debug”,“msg”:“Received HTTP request”,“fields”:{“method”:“POST”,“request_id”:“ki59gt71hpgyxm3w3q8qg4tcgw”,“status_code”:“200”,“url”:“/api/v4/channels/members/me/view”}}
{“level”:“debug”,“msg”:“Received HTTP request”,“fields”:{“method”:“POST”,“request_id”:“rq6uzrk5atyuxksemx1pzcrrto”,“status_code”:“200”,“url”:“/api/v4/channels/members/me/view”}}
{“level”:“debug”,“msg”:“Received HTTP request”,“fields”:{“method”:“POST”,“request_id”:“czun6zd1nbnd8cztuhyw36dcgc”,“status_code”:“201”,“url”:“/api/v4/files”}}
{“level”:“warn”,“msg”:“Failed to invalidate the fileInfo cache.”,“fields”:{“error”:“"failed to get FileInfo with id=3xer9ogn73g7mep1bm5uzr6bdh: Error 1054: Unknown column ‘FileInfo.Archived’ in ‘field list’"”,“file_info_id”:“3xer9ogn73g7mep1bm5uzr6bdh”}}

I can see the file on the server . I do not see the FileInfo.Archived filed in the database
I also see this in the logs {“level”:“fatal”,“msg”:“Failed to apply database migrations.”,“fields”:{“error”:“"open migrations\mysql: file does not exist"”}}

Hi,

can you provde some additional information about your deployment, please? Is this a custom build or an official one and what’s the platform you’re running on? Could it be that this is a windows host? If so I’m sorry to say that but Windows is not officially supported as a host platform.

Your database is clearly missing some migrations as you’ve seen, so in order to find out at what migration version you are, please run the following SQL query:

select max(Version) from db_migrations;

This command will return a number. Mattermost 7.0.2 was running on version 85, so if this is the number you’re seeing here, then none of the migrations after 7.0.2 have been applied. If you upgraded to 7.5.1 now, you need to manually run the migrations for this release. To do that, make sure your Mattermost application server is stopped and get a list of the SQL files by browsing the mattermost server code at GitHub for the release you’re running. I’m assuming you tried to install 7.5.1 now, if this assumption is not correct, please just replace the version in the URL:

You can see that 7.5.1’s max migration version is 95, so assuming that you’re on 85, you need to manually upgrade the versions 86 to 95.
You’re interested in the .up.sql files (because you want to upgrade your server to the new schema), so looking at the migration with ID 86, you can just copy and paste what you see here into your MySQL console to manually apply this migration:

Continue until you reach the highest version necessary for the release you installed.
When all migrations applied successfully without error messages, you can start the application server again and it should work again. If there are any error during the migrations or if it still doesn’t work then, please post logs and error messages again.

@agriesser

Ok so i am running 7.2.1 and the schema version was at 77.

So I ran the up migration files up to 90 all worked and that actually took care of the file upload issue. But looks like the db_migrations db does not get updated doing them manually do I need to update the migrations db to 90 so it does not try and run migrations when service is started

Yes, you could do that manually. These are the contents of this table on one of my demo systems, please insert the values according to the max supported version of the installed mattermost version:

mysql> select * from db_migrations where Version > 77;
+---------+---------------------------------+
| Version | Name                            |
+---------+---------------------------------+
|      78 | create_oauth_mattermost_app_id  |
|      79 | usergroups_displayname_index    |
|      80 | posts_createat_id               |
|      81 | threads_deleteat                |
|      82 | upgrade_oauth_mattermost_app_id |
|      83 | threads_threaddeleteat          |
|      84 | recent_searches                 |
|      85 | fileinfo_add_archived_column    |
|      86 | add_cloud_limits_archived       |
|      87 | sidebar_categories_index        |
|      88 | remaining_migrations            |
|      89 | add-channelid-to-reaction       |
|      90 | create_enums                    |
|      91 | create_post_reminder            |
|      92 | add_createat_to_teammembers     |
|      93 | notify_admin                    |
+---------+---------------------------------+
16 rows in set (0.00 sec)

So seems I updated the db but when starting the server it is still trying to perform database migrations. and will actually abort the start up.

@agriesser

So seems I updated the db but when starting up it still seems to look for db migrations
{“level”:“error”,“msg”:“Could not initiate logging”,“fields”:{“error”:“"invalid config for logging, error creating log target _defFile: error decoding file target options: invalid character ‘L’ in string escape code"”}}
{“level”:“info”,“msg”:“Server is initializing…”,“fields”:{“go_version”:“go1.18.1”}}
{“level”:“info”,“msg”:“Pinging SQL”,“fields”:{“database”:“master”}}
{“level”:“fatal”,“msg”:“Failed to apply database migrations.”,“fields”:{“error”:“"open migrations\mysql: file does not exist"”}}
{“level”:“debug”,“msg”:“Deleting any unused pre-release features”}
{“level”:“info”,“msg”:“License key valid unlocking enterprise features.”}
{“level”:“debug”,“msg”:“Hub is starting”,“fields”:{“index”:“0”}}
{“level”:“debug”,“msg”:“Hub is starting”,“fields”:{“index”:“1”}}
{“level”:“debug”,“msg”:“Hub is starting”,“fields”:{“index”:“3”}}
{“level”:“debug”,“msg”:“Hub is starting”,“fields”:{“index”:“2”}}
{“level”:“debug”,“msg”:“Hub is starting”,“fields”:{“index”:“5”}}
{“level”:“debug”,“msg”:“Hub is starting”,“fields”:{“index”:“4”}}
{“level”:“debug”,“msg”:“Hub is starting”,“fields”:{“index”:“6”}}
{“level”:“debug”,“msg”:“Hub is starting”,“fields”:{“index”:“7”}}
{“level”:“info”,“msg”:“Loaded system translations”,“fields”:{“for locale”:“en”,“from locale”:“"C:\mattermost\i18n\en.json"”}}
{“level”:“info”,“msg”:“Current version is 6.7.2 (6.7.2/Wed Jun 15 20:14:35 UTC 2022/d565c9595e08fe87d520f4ab2fa55e8f5a065f9c/85a9ff217056a0daa3c7a3bc12d960d4b7cf6b12)”,“fields”:{“build_date”:“"Wed Jun 15 20:14:35 UTC 2022"”,“build_hash”:“d565c9595e08fe87d520f4ab2fa55e8f5a065f9c”,“build_hash_enterprise”:“85a9ff217056a0daa3c7a3bc12d960d4b7cf6b12”,“build_number”:“6.7.2”,“current_version”:“6.7.2”}}

Hi,

I’m not sure where it tries to access this directory, since the migrations in cleartext are not part of the filesystem structure at all in the binary deployments. Looking at the code, we probably fail here:

func (ss *SqlStore) migrate(direction migrationDirection) error {
        assets := db.Assets()

        assetsList, err := assets.ReadDir(filepath.Join("migrations", ss.DriverName()))
        if err != nil {
                return err
        }

Additionally your log directory path seems to be invalid, see the first error message in your output. It complains about \L being an invalid escape character, so I assume that you have a path in your config.json where the \ character is not escaped properly with regards to your logging configuration, can you check the FileLocation setting in the LogSettings section?

Also, did you try to downgrade to 6.7.2 again after running the migrations? The error messages you showed cleary state that the server version 6.7.2 has been started and I though you wanted to upgrade to 7+?

@agriesser

Ok So I have been trying a few things. Right now I upgraded from 6.7.2 with the DB at 82 and upgraded to 7.0.2, migrations did not run. Funny the server is starts up if migrations fail.

So I will do the migrations manually. But even when I do it that way it still try’s to run the migration process on start up.

so for the logs here is what I have tried with no luck
“LogSettings”: {
“EnableConsole”: true,
“ConsoleLevel”: “INFO”,
“ConsoleJson”: true,
“EnableColor”: false,
“EnableFile”: true,
“FileLevel”: “INFO”,
“FileJson”: true,
“FileLocation”: “C://mattermost//log”,
“EnableWebhookDebugging”: true,
“EnableDiagnostics”: true,
“EnableSentry”: true,
“AdvancedLoggingConfig”: “”

Tried C:/mattermost/log
Tried C:\mattermost\log
Tried C:\mattermost\log

Get same error no matter what.

{“level”:“error”,“msg”:“Could not initiate logging”,“fields”:{“error”:“"invalid config for logging, error creating log target _defFile: error decoding file target options: invalid character ‘m’ in string escape code"”}}
{“level”:“info”,“msg”:“Server is initializing…”,“fields”:{“go_version”:“go1.18.1”}}
{“level”:“info”,“msg”:“Pinging SQL”,“fields”:{“database”:“master”}}
{“level”:“fatal”,“msg”:“Failed to apply database migrations.”,“fields”:{“error”:“"open migrations\mysql: file does not exist"”}}
{“level”:“debug”,“msg”:“Deleting any unused pre-release features”}
{“level”:“info”,“msg”:“License key valid unlocking enterprise features.”}
{“level”:“debug”,“msg”:“Hub is starting”,“fields”:{“index”:“1”}}
{“level”:“debug”,“msg”:“Hub is starting”,“fields”:{“index”:“0”}}
{“level”:“debug”,“msg”:“Hub is starting”,“fields”:{“index”:“4”}}
{“level”:“debug”,“msg”:“Hub is starting”,“fields”:{“index”:“2”}}
{“level”:“debug”,“msg”:“Hub is starting”,“fields”:{“index”:“3”}}
{“level”:“debug”,“msg”:“Hub is starting”,“fields”:{“index”:“6”}}
{“level”:“debug”,“msg”:“Hub is starting”,“fields”:{“index”:“5”}}
{“level”:“debug”,“msg”:“Hub is starting”,“fields”:{“index”:“7”}}
{“timestamp”:“2022-12-09 08:25:56.840 -06:00”,“level”:“info”,“msg”:“Starting websocket hubs”,“caller”:“app/web_hub.go:93”,“number_of_hubs”:8}
{“level”:“info”,“msg”:“Loaded system translations”,“fields”:{“for locale”:“en”,“from locale”:“"C:\mattermost\i18n\en.json"”}}
{“level”:“info”,“msg”:“Current version is 7.0.2 (7.0.2/Wed Aug 17 13:31:25 UTC 2022/97957fee70257dbc8d7eaadaab6999116d7b9aed/4e9115afacb00db24a781b91f3dd18a479fd9bc6)”,“fields”:{“build_date”:“"Wed Aug 17 13:31:25 UTC 2022"”,“build_hash”:“97957fee70257dbc8d7eaadaab6999116d7b9aed”,“build_hash_enterprise”:“4e9115afacb00db24a781b91f3dd18a479fd9bc6”,“build_number”:“7.0.2”,“current_version”:“7.0.2”}}

Here is my Upgrade path I am doing
6.7.2 >> 7.0.2
7.0.2 >> 7.1.4
7.1.4 >> 7.2.1
7.2.1 >> 7.3.1

So I upgraded to the current 7.1.4 version. the file uploads are working after running all the migration code manually. Still errors about migrations on startup but seems to run the server

1 Like

Thanks for sharing this information, so you’re saying that it breaks when you try to upgrade to 7.2.1 so 7.1.4 is the most recent version you can use on Windows, right?

@agriesser

So we normally only run Extended Support Release versions. So right now that is 7.1.4.

The file upload issue seems to have been because the migrations are not working, they never got performed and the new Editor seems to have needed a DB update for them to work. When I run all the UP migrations scripts manually starting at 6.7.2 to 7.1.4 then the Upload file issue is resolved. :grinning:

Still seem to have a Auto migration issue with the releases.