Import from slack: BulkImport: Some users not found

Summary
I am using mattermost 10.5.7 in local mode. I am trying to import from slack following: Migrate from Slack - Mattermost documentation

When I execute:

/mattermost/bin/mmctl --local import process --bypass-upload /mm_import/mattermost-bulk-import-FIXED.zip

/mattermost/bin/mmctl --local import job show j6pzoryx83drmeygjoe73qy8sh
  ID: j6pzoryx83drmeygjoe73qy8sh
  Type: import_process
  Status: error
  Created: 2025-06-04 17:28:10 +0000 UTC
  Started: 2025-06-04 17:28:15 +0000 UTC
  Data: map[error:Error during job execution. — BulkImport: Some users not found extract_content:true import_file:/mm_import/mattermost-bulk-import-FIXED.zip line_number:106 local_mode:true]

Steps to reproduce
I am using 10.5.7. I can’t send you the file without a proper NDA etc.

Expected behavior
I am following the slack migration guide, so I would expect the file can be successfully processed.

Observed behavior
The error seems to be implying line 106 from the jsonl file is “wrong”. So here is the line:

106 {"type":"direct_channel","direct_channel":{"members":["Ralph","Patrick","Joshua","Sasha"],"favorited_by":null,"header":""}}

I manually verified that all users Ralph … are properly defined previously like:

{"type":"user","user":{"username":"Ralph","email":"Ralph@example.com","auth_service":null,"nickname":"","first_name":"Ralph","last_name":"LastName","position":"","roles":"system_user","locale":null,"teams":[{"name":"my-team","roles":"team_user","channels":[{"name":"general","roles":"channel_user"},{"name":"random","roles":"channel_user"},...]}]}}

Is there some way for me to get more details as to why mattermost thinks some users are not found, even though it seems otherwise.

Hi @shinewu - Could you post the Mattermost log during this import process?

Thanks! I deleted some bloat from the log, but I did not see anything more informative:

{"timestamp":"2025-06-05 16:02:29.850 Z","level":"info","msg":"Starting workers for new segment","caller":"app/import.go:269","old_segment":"version","new_segment":"channel","workers":12}
{"timestamp":"2025-06-05 16:02:29.853 Z","level":"info","msg":"Started new bulk import worker","caller":"app/import.go:128","bulk_import_worker_id":"6z3dwkqd9jrxpma4wc8dhg7a5c"}
{"timestamp":"2025-06-05 16:02:29.853 Z","level":"info","msg":"Started new bulk import worker","caller":"app/import.go:128","bulk_import_worker_id":"5zu6dnwoa3d5mq5pc868t6461y"}
{"timestamp":"2025-06-05 16:02:29.853 Z","level":"info","msg":"Validating channel","caller":"app/import_functions.go:258","channel_name":"general"}
{"timestamp":"2025-06-05 16:02:29.853 Z","level":"info","msg":"Validating channel","caller":"app/import_functions.go:258","channel_name":"random"}
{"timestamp":"2025-06-05 16:02:29.853 Z","level":"info","msg":"Importing channel","caller":"app/import_functions.go:272","channel_name":"general"}
{"timestamp":"2025-06-05 16:02:29.853 Z","level":"info","msg":"Importing channel","caller":"app/import_functions.go:272","channel_name":"random"}
{"timestamp":"2025-06-05 16:02:29.853 Z","level":"info","msg":"Started new bulk import worker","caller":"app/import.go:128","bulk_import_worker_id":"kdqwfn9j4bykuf7ur4ddk56aye"}
...
{"timestamp":"2025-06-05 16:02:29.979 Z","level":"info","msg":"Finished parsing segment, waiting for workers to finish","caller":"app/import.go:250","old_segment":"channel","new_segment":"user"}
...
{"timestamp":"2025-06-05 16:02:29.999 Z","level":"info","msg":"Bulk import worker finished","caller":"app/import.go:131","bulk_import_worker_id":"5crtxx1ah3b1fjoy16xghdyt5e","processed_lines":2}
{"timestamp":"2025-06-05 16:02:30.001 Z","level":"info","msg":"Bulk import worker finished","caller":"app/import.go:131","bulk_import_worker_id":"6z3dwkqd9jrxpma4wc8dhg7a5c","processed_lines":1}
{"timestamp":"2025-06-05 16:02:30.001 Z","level":"info","msg":"Bulk import worker finished","caller":"app/import.go:131","bulk_import_worker_id":"m4n9gp8bajd9xno3x6rhzwjd1c","processed_lines":2}
{"timestamp":"2025-06-05 16:02:30.002 Z","level":"info","msg":"Bulk import worker finished","caller":"app/import.go:131","bulk_import_worker_id":"j6w6dg9hgb8euczykrzhegokto","processed_lines":4}
{"timestamp":"2025-06-05 16:02:30.002 Z","level":"info","msg":"Bulk import worker finished","caller":"app/import.go:131","bulk_import_worker_id":"6fexgywwu7bbtjkzhf5b9sfjuc","processed_lines":1}
{"timestamp":"2025-06-05 16:02:30.005 Z","level":"info","msg":"Bulk import worker finished","caller":"app/import.go:131","bulk_import_worker_id":"syx6osfoz78ntpep9nfissokmw","processed_lines":5}
{"timestamp":"2025-06-05 16:02:30.005 Z","level":"info","msg":"Bulk import worker finished","caller":"app/import.go:131","bulk_import_worker_id":"kdqwfn9j4bykuf7ur4ddk56aye","processed_lines":4}
{"timestamp":"2025-06-05 16:02:30.006 Z","level":"info","msg":"Bulk import worker finished","caller":"app/import.go:131","bulk_import_worker_id":"bsxp4k3eoj8b9qjkewgjnc9xqy","processed_lines":5}
{"timestamp":"2025-06-05 16:02:30.007 Z","level":"info","msg":"Bulk import worker finished","caller":"app/import.go:131","bulk_import_worker_id":"5zu6dnwoa3d5mq5pc868t6461y","processed_lines":3}
{"timestamp":"2025-06-05 16:02:30.007 Z","level":"info","msg":"Bulk import worker finished","caller":"app/import.go:131","bulk_import_worker_id":"xc1168jxufde9eqg978cqig1da","processed_lines":3}
{"timestamp":"2025-06-05 16:02:30.007 Z","level":"info","msg":"Bulk import worker finished","caller":"app/import.go:131","bulk_import_worker_id":"39cfyms8bpda7kfosc58h95jke","processed_lines":2}
{"timestamp":"2025-06-05 16:02:30.008 Z","level":"info","msg":"Bulk import worker finished","caller":"app/import.go:131","bulk_import_worker_id":"oz6n99zyj7g6uxoqz58c5pgodc","processed_lines":2}
{"timestamp":"2025-06-05 16:02:30.008 Z","level":"info","msg":"Starting workers for new segment","caller":"app/import.go:269","old_segment":"channel","new_segment":"user","workers":12}
...
{"timestamp":"2025-06-05 16:02:30.008 Z","level":"info","msg":"Started new bulk import worker","caller":"app/import.go:128","bulk_import_worker_id":"7g9mkagry3n9dpyqswuzemgd5w"}
{"timestamp":"2025-06-05 16:02:30.008 Z","level":"info","msg":"Validating user","caller":"app/import_functions.go:342","user_name":"Joel"}
{"timestamp":"2025-06-05 16:02:30.008 Z","level":"info","msg":"Importing user","caller":"app/import_functions.go:353","user_name":"Joel"}
...
{"timestamp":"2025-06-05 16:02:30.756 Z","level":"info","msg":"Finished parsing segment, waiting for workers to finish","caller":"app/import.go:250","old_segment":"user","new_segment":"direct_channel"}
...
{"timestamp":"2025-06-05 16:02:31.017 Z","level":"info","msg":"Bulk import worker finished","caller":"app/import.go:131","bulk_import_worker_id":"fh6hjt7p7bbhpy7jzx7sxmedqh","processed_lines":6}
{"timestamp":"2025-06-05 16:02:31.019 Z","level":"info","msg":"Bulk import worker finished","caller":"app/import.go:131","bulk_import_worker_id":"pozbox3fk3nnicfdgwupiy19ny","processed_lines":6}
{"timestamp":"2025-06-05 16:02:31.021 Z","level":"info","msg":"Bulk import worker finished","caller":"app/import.go:131","bulk_import_worker_id":"hthzi9jqrbrhdxyagor8kmc5er","processed_lines":6}
{"timestamp":"2025-06-05 16:02:31.023 Z","level":"info","msg":"Bulk import worker finished","caller":"app/import.go:131","bulk_import_worker_id":"4duaec4sop8upffs39q7onhx4a","processed_lines":4}
{"timestamp":"2025-06-05 16:02:31.030 Z","level":"info","msg":"Bulk import worker finished","caller":"app/import.go:131","bulk_import_worker_id":"4xsoyffy57d9pynjmff7n7yoyo","processed_lines":6}
{"timestamp":"2025-06-05 16:02:31.039 Z","level":"info","msg":"Bulk import worker finished","caller":"app/import.go:131","bulk_import_worker_id":"7g9mkagry3n9dpyqswuzemgd5w","processed_lines":6}
{"timestamp":"2025-06-05 16:02:31.043 Z","level":"info","msg":"Bulk import worker finished","caller":"app/import.go:131","bulk_import_worker_id":"1jjpwacuip8wpc7uaf7ozdn5sa","processed_lines":4}
{"timestamp":"2025-06-05 16:02:31.045 Z","level":"info","msg":"Bulk import worker finished","caller":"app/import.go:131","bulk_import_worker_id":"nh5acb5p7bfytp36z6u9t493fa","processed_lines":6}
{"timestamp":"2025-06-05 16:02:31.047 Z","level":"info","msg":"Bulk import worker finished","caller":"app/import.go:131","bulk_import_worker_id":"p9girwm6z3y7j8ws7k5h698tph","processed_lines":3}
{"timestamp":"2025-06-05 16:02:31.067 Z","level":"info","msg":"Bulk import worker finished","caller":"app/import.go:131","bulk_import_worker_id":"ehpm69qmbin9zkoe3gzrn5deda","processed_lines":7}
{"timestamp":"2025-06-05 16:02:31.080 Z","level":"info","msg":"Bulk import worker finished","caller":"app/import.go:131","bulk_import_worker_id":"9o17ss1od7fo7c9wbt4cxx8ihc","processed_lines":5}
{"timestamp":"2025-06-05 16:02:31.155 Z","level":"info","msg":"Bulk import worker finished","caller":"app/import.go:131","bulk_import_worker_id":"cys5khwntt848rutx9nda7mx7e","processed_lines":4}
{"timestamp":"2025-06-05 16:02:31.157 Z","level":"info","msg":"Starting workers for new segment","caller":"app/import.go:269","old_segment":"user","new_segment":"direct_channel","workers":12}
{"timestamp":"2025-06-05 16:02:31.158 Z","level":"info","msg":"Started new bulk import worker","caller":"app/import.go:128","bulk_import_worker_id":"m6aycd7bz7ywig7xscwyq4w6be"}
{"timestamp":"2025-06-05 16:02:31.158 Z","level":"info","msg":"Started new bulk import worker","caller":"app/import.go:128","bulk_import_worker_id":"ggwdjfiieprrpge65fmk4sjmqc"}
{"timestamp":"2025-06-05 16:02:31.158 Z","level":"info","msg":"Started new bulk import worker","caller":"app/import.go:128","bulk_import_worker_id":"feabp8f1dfbu9rdqn4hc6fao1r"}
{"timestamp":"2025-06-05 16:02:31.158 Z","level":"info","msg":"Started new bulk import worker","caller":"app/import.go:128","bulk_import_worker_id":"wwtyman8ti8eunjadjhzehedhy"}
{"timestamp":"2025-06-05 16:02:31.158 Z","level":"info","msg":"Started new bulk import worker","caller":"app/import.go:128","bulk_import_worker_id":"bp19bupxz3nef86k4x4t9srh6r"}
{"timestamp":"2025-06-05 16:02:31.158 Z","level":"info","msg":"Started new bulk import worker","caller":"app/import.go:128","bulk_import_worker_id":"4tgzwdz1i7njpe718zdx1b6fjw"}
{"timestamp":"2025-06-05 16:02:31.158 Z","level":"info","msg":"Started new bulk import worker","caller":"app/import.go:128","bulk_import_worker_id":"po3bk1mdhbbbmbuizik1kncmmo"}
{"timestamp":"2025-06-05 16:02:31.158 Z","level":"info","msg":"Started new bulk import worker","caller":"app/import.go:128","bulk_import_worker_id":"3qk9jp3xsbg1iywstuc1tcjq9y"}
{"timestamp":"2025-06-05 16:02:31.158 Z","level":"info","msg":"Started new bulk import worker","caller":"app/import.go:128","bulk_import_worker_id":"g976xqkibifd9fwqg8owd43bwe"}
{"timestamp":"2025-06-05 16:02:31.158 Z","level":"info","msg":"Started new bulk import worker","caller":"app/import.go:128","bulk_import_worker_id":"hfmghbh4xt89pfr8b56q9w15fw"}
{"timestamp":"2025-06-05 16:02:31.158 Z","level":"info","msg":"Started new bulk import worker","caller":"app/import.go:128","bulk_import_worker_id":"7crwaj7tjtgrzqhhtpdjh3o1or"}
{"timestamp":"2025-06-05 16:02:31.158 Z","level":"info","msg":"Started new bulk import worker","caller":"app/import.go:128","bulk_import_worker_id":"new6nzez3jyhj8fwrobhpixo8e"}
{"timestamp":"2025-06-05 16:02:31.163 Z","level":"info","msg":"Bulk import worker finished","caller":"app/import.go:131","bulk_import_worker_id":"po3bk1mdhbbbmbuizik1kncmmo","processed_lines":3}
{"timestamp":"2025-06-05 16:02:31.164 Z","level":"info","msg":"Bulk import worker finished","caller":"app/import.go:131","bulk_import_worker_id":"feabp8f1dfbu9rdqn4hc6fao1r","processed_lines":2}
{"timestamp":"2025-06-05 16:02:31.164 Z","level":"info","msg":"Bulk import worker finished","caller":"app/import.go:131","bulk_import_worker_id":"wwtyman8ti8eunjadjhzehedhy","processed_lines":2}
{"timestamp":"2025-06-05 16:02:31.164 Z","level":"info","msg":"Bulk import worker finished","caller":"app/import.go:131","bulk_import_worker_id":"g976xqkibifd9fwqg8owd43bwe","processed_lines":3}
{"timestamp":"2025-06-05 16:02:31.164 Z","level":"info","msg":"Bulk import worker finished","caller":"app/import.go:131","bulk_import_worker_id":"3qk9jp3xsbg1iywstuc1tcjq9y","processed_lines":2}
{"timestamp":"2025-06-05 16:02:31.165 Z","level":"info","msg":"Bulk import worker finished","caller":"app/import.go:131","bulk_import_worker_id":"ggwdjfiieprrpge65fmk4sjmqc","processed_lines":2}
{"timestamp":"2025-06-05 16:02:31.165 Z","level":"info","msg":"Bulk import worker finished","caller":"app/import.go:131","bulk_import_worker_id":"bp19bupxz3nef86k4x4t9srh6r","processed_lines":1}
{"timestamp":"2025-06-05 16:02:31.165 Z","level":"info","msg":"Bulk import worker finished","caller":"app/import.go:131","bulk_import_worker_id":"new6nzez3jyhj8fwrobhpixo8e","processed_lines":1}
{"timestamp":"2025-06-05 16:02:31.165 Z","level":"info","msg":"Bulk import worker finished","caller":"app/import.go:131","bulk_import_worker_id":"hfmghbh4xt89pfr8b56q9w15fw","processed_lines":2}
{"timestamp":"2025-06-05 16:02:31.166 Z","level":"info","msg":"Bulk import worker finished","caller":"app/import.go:131","bulk_import_worker_id":"m6aycd7bz7ywig7xscwyq4w6be","processed_lines":2}
{"timestamp":"2025-06-05 16:02:31.166 Z","level":"info","msg":"Bulk import worker finished","caller":"app/import.go:131","bulk_import_worker_id":"7crwaj7tjtgrzqhhtpdjh3o1or","processed_lines":2}
{"timestamp":"2025-06-05 16:02:31.166 Z","level":"info","msg":"Bulk import worker finished","caller":"app/import.go:131","bulk_import_worker_id":"4tgzwdz1i7njpe718zdx1b6fjw","processed_lines":2}
{"timestamp":"2025-06-05 16:02:31.167 Z","level":"error","msg":"SimpleWorker: job execution error","caller":"jobs/base_workers.go:86","worker_name":"ImportProcess","job_id":"ibtxjtxputdfumhig1yfu9an3c","job_type":"import_process","job_create_at":"Jun  5 16:02:17.598","error":"BulkImport: Some users not found"}

In the logs, I can also find the lines for all users on line 106:

106 {"type":"direct_channel","direct_channel":{"members":["Ralph","Patrick","Joshua","Sasha"],"favorited_by":null,"header":""}}

Here are the lines for the last user Sasha

{"timestamp":"2025-06-05 16:02:30.705 Z","level":"info","msg":"Validating user","caller":"app/import_functions.go:342","user_name":"Sasha"}
{"timestamp":"2025-06-05 16:02:30.705 Z","level":"info","msg":"Importing user","caller":"app/import_functions.go:353","user_name":"Sasha"}

Thanks @shinewu. The error message is slightly misleading, and it does not give additional context.

The error is coming from here:

if len(allUsers) != len(uniqueUsernames) {
		return nil, model.NewAppError("BulkImport", "app.import.get_users_by_username.some_users_not_found.error", nil, "", http.StatusBadRequest)
	}

allUsers is the list of users fetched from the store, and uniqueUsernames is the list of unique usernames, in your case it would be ["Ralph","Patrick","Joshua","Sasha"].

Just for confirmation, before this line 106, all of the 4 users have been imported right? Can you see “Importing user” lines for all 4 users?

Ah sorry, you just said that in the logs you can find the lines for all users.

I wonder if there’s some incorrect data in the DB. Could you run this query in the DB?

SELECT Users.Id, Users.CreateAt, Users.UpdateAt, Users.DeleteAt, Users.Username, Users.Password, Users.AuthData, Users.AuthService, Users.Email, Users.EmailVerified, Users.Nickname, Users.FirstName, Users.LastName, Users.Position, Users.Roles, Users.AllowMarketing, Users.Props, Users.NotifyProps, Users.LastPasswordUpdate, Users.LastPictureUpdate, Users.FailedAttempts, Users.Locale, Users.Timezone, Users.MfaActive, Users.MfaSecret, Users.MfaUsedTimestamps, Users.RemoteId, Users.LastLogin, b.UserId IS NOT NULL AS IsBot, COALESCE(b.Description, '') AS BotDescription, COALESCE(b.LastIconUpdate, 0) AS BotLastIconUpdate FROM Users LEFT JOIN Bots b ON ( b.UserId = Users.Id ) WHERE Username IN ('Ralph','Patrick', 'Joshua', 'Sasha') ORDER BY Users.Username ASC

And check what output you get?

Strange, I can’t find them:

mattermost=> SELECT Users.Id, Users.CreateAt, Users.UpdateAt, Users.DeleteAt, Users.Username, Users.Password, Users.AuthData, Users.AuthService, Users.Email, Users.EmailVerified, Users.Nickname, Users.FirstName, Users.LastName, Users.Position, Users.Roles, Users.AllowMarketing, Users.Props, Users.NotifyProps, Users.LastPasswordUpdate, Users.LastPictureUpdate, Users.FailedAttempts, Users.Locale, Users.Timezone, Users.MfaActive, Users.MfaSecret, Users.MfaUsedTimestamps, Users.RemoteId, Users.LastLogin, b.UserId IS NOT NULL AS IsBot, COALESCE(b.Description, '') AS BotDescription, COALESCE(b.LastIconUpdate, 0) AS BotLastIconUpdate FROM Users LEFT JOIN Bots b ON ( b.UserId = Users.Id ) WHERE Username IN ('Ralph','Patrick', 'Joshua', 'Sasha') ORDER BY Users.Username ASC
mattermost->
mattermost-> ;
 id | createat | updateat | deleteat | username | password | authdata | authservice | email | emailverified | nickname | firstname | lastname | position | roles | allowmarketing | props | notifyprops | lastpasswordupdate | lastpictureupdate  | failedattempts | locale | timezone | mfaactive | mfasecret | mfausedtimestamps | remoteid | lastlogin | isbot | botdescription | botlasticonupdate
----+----------+----------+----------+----------+----------+----------+-------------+-------+---------------+----------+-----------+----------+----------+-------+----------------+-------+-------------+--------------------+-------------------+----------------+--------+----------+-----------+-----------+-------------------+----------+-----------+-------+----------------+-------------------
(0 rows)

I also did this:

SELECT DISTINCT Users.username FROM Users;

I noticed that all usernames are lower case now.

So I changed your query to use lower case user name as (‘ralph’,‘patrick’, ‘joshua’, ‘sasha’):

mattermost=> SELECT Users.Id, Users.CreateAt, Users.UpdateAt, Users.DeleteAt, Users.Username, Users.Password, Users.AuthData, Users.AuthService, Users.Email, Users.EmailVerified, Users.Nickname, Users.FirstName, Users.LastName, Users.Position, Users.Roles, Users.AllowMarketing, Users.Props, Users.NotifyProps, Users.LastPasswordUpdate, Users.LastPictureUpdate, Users.FailedAttempts, Users.Locale, Users.Timezone, Users.MfaActive, Users.MfaSecret, Users.MfaUsedTimestamps, Users.RemoteId, Users.LastLogin, b.UserId IS NOT NULL AS IsBot, COALESCE(b.Description, '') AS BotDescription, COALESCE(b.LastIconUpdate, 0) AS BotLastIconUpdate FROM Users LEFT JOIN Bots b ON ( b.UserId = Users.Id ) WHERE Username IN ('ralph','patrick', 'joshua', 'sasha') ORDER BY Users.Username ASC;
             id             |   createat    |   updateat    | deleteat | username |                           password                           | authdata | authservice |        email        | emailverified | nickname | firstname | lastname  | position |    roles    | allowmarketing | props |                                                                                                                               notifyprops                                                                                                                                | lastpasswordupdate | lastpictureupdate | failedattempts | locale |                                    timezone                                     | mfaactive | mfasecret | mfausedtimestamps | remoteid | lastlogin | isbot | botdescription | botlasticonupdate
----------------------------+---------------+---------------+----------+----------+--------------------------------------------------------------+----------+-------------+---------------------+---------------+----------+-----------+-----------+----------+-------------+----------------+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------+-------------------+----------------+--------+---------------------------------------------------------------------------------+-----------+-----------+-------------------+----------+-----------+-------+----------------+-------------------
... good data ...
(4 rows)

Now I can find all 4 rows and they all look right. What does this tell us?

Oh well, looks like you have found a bug!

We lowercase the usernames while inserting the users, but while checking for the users in the DB, we don’t lowercase them!

We did try to fix it: [MM-51468] import: allow usernames to be uppercase by isacikgoz · Pull Request #29530 · mattermost/mattermost · GitHub. But it looks like we missed a case. cc @isacikgoz

For now, I’d suggest to lowercase all usernames in your import file. I will file a ticket for this. Sorry for the inconvenience!

So you are saying if I want to move forward without the fix from the mattermost team, I can just go search and replace all user names to lower cases?

How long do you think it takes for your team to release a fix?

Correct.

The code review + QA testing takes around a week or so depending on the workload. Then once merged, it should appear in the next release. It would be awesome if you want to send a fix yourself. That would accelerate the process.

I am probably not equipped to fix it cleanly at this point.

There are some strange side-effects with the lower-all-user-names approach. For instance, in many messages, user names do show up as “@John”, if I lowered the original “John” user to “john”, seems like this message will then be inconsistent with the users in the db.

Yeah an ideal fix would be making the user lookup to be case-insensitive.

Okay I think I managed to hack together a solution to replace all user appearances in lower cases. It is ugly. And I will move forward for now. But I would appreciate a proper fix. Thanks a lot!