Error”: “We could not count the users.“, in slack to mattermost migration

Kindly guide me
We were using the Slack and now we want to shift on Mattermost.
While during the migration of Slack data on to Mattermost we are facing this issue.

error”: “We could not count the users.“

Hi m-talha-Saleem22 and welcome to the Mattermost forums!

At which point did you receive this error message? Can you maybe share the exact command you entered as well as the exact outupt you were seeing?

@agriesser First thank you so much for your quick response.
The link for the guide used is Migration guide — Mattermost documentation
Followed all steps in the “Migrating from Slack using the Mattermost mmetl tool and bulk import” section, including step 5 “Import into mattermost”. Executing the command mmctl import job show <JOB ID> --json, results in the error shown below, also visible in the attached screenshot.

"id": "d1q664fot7foxxpp65ppjoz3dy",
"type": "import_process",
"priority": 0,
"create_at": 1663068926457,
"start_at": 1663068937595,
"last_activity_at": 1663068937629,
"status": "error",
"progress": -1,
"data": {
"error": "We could not count the users.",
"import_file": "",
"line_number": "2"

cc @plusmid

1 Like

Thanks for the ping @agnivade.

There are a few thing going wrong here:
1: The error message is wrong. For some reason each error in SimpleJob is translated as “We could not count the users.”.
2: The output should contain the original error but doesn’t since we changed how it’s propagated through the server.

The underlying issue can be found in line 2 (that should be accurate) of the .jsonl file in your import ZIP.

edit: @m-talha-Saleem22 you should be able to find the actual error in the logs, search for SimpleWorker: job execution error

1 Like

Sent a fix for #1 here: job server: Remove incorrect error code by agnivade · Pull Request #21030 · mattermost/mattermost-server · GitHub

@agnivade thanks but there is already a PR addressing both issues: MM-46990 Report correct import error by noxer · Pull Request #21025 · mattermost/mattermost-server · GitHub

Sorry, should have posted it here as well :worried:

First of all I would like to thank you for your help @plusmid and @agnivade . The log error you mentioned helped us a lot to track the exact issue we were facing. It was the name of the team that was to be typed in the ./mmetl transform slack --team <TEAM NAME> --file --output mattermost_import.jsonl command. The team name we were adding earlier had the first letter capital in uppercase i.e. “Migrated-from-manzoor”. Changing the whole team name to lowercase (“migrated-from-manzoor”) solved the issue.
For further context, here is the log of the error generated in the mattermost.log file:
{"timestamp":"2022-09-14 15:43:22.734 +05:00","level":"error","msg":"SimpleWorker: job execution error","caller":"jobs/base_workers.go:83","worker":"ImportProcess","job_id":"m8jzzg54qifo7bxxwnyr4jfikw","error":"BulkImport: Error importing channel. Team with name \"Migrated-from-manzoor\" could not be found., resource: Team id: name=Migrated-from-manzoor"}

Awesome @m-talha-Saleem22, glad this could be resolved. Were there any other issues during the import?

@plusmid We are still working on the import. The import takes place successfully and the json file generated from the final command mmctl import job show <JOB ID> --json gives the output of success.
However, we are unable to login with the users imported from slack, as their slack passwords are not working.
Referring to this link: Import from Mattermost | Zulip help center, we found the reason for this to be the fact that the emails are imported successfully but the passwords are not imported due to security reasons. We are now unsure as to how the passwords can be reset for all the users, since even the admin password gets overwritten and as a result the admin gets locked out of mattermost once we logout from mattermost in the event that the admin on mattermost and slack has the same email address.
One workaround for this might be to try a password reset via the ‘forgot your password’ option, however, this option is not yet functional on our end which is why we are looking for an alternative for changing or resetting password.
Any suggestion or help please?

You could reset the password using mmctl on the Mattermost server directly. Make sure to enable local access in the Mattermost server configuration (config.json option is called ServiceSettings.EnableLocalMode and requires a restart) and you can then use mmctl --local user change-password command or the reset-password command.
Since you do have all the users in a json file it’s pretty easy to walk through them in a loop.

Using your mattermost_import.jsonl file, you could do something like this:

for user in $(jq -r '(select(.type  | startswith("user"))).user.username' mattermost_import.jsonl); do
  mmctl --local user change-password $user --password <new-password>
1 Like

Hy @plusmid @agriesser, During migration from slack to mattermost using mmctl We got this error: "timestamp":"2022-09-15 19:29:33.583 Z","level":"error","msg":"SimpleWorker: job execution error","caller":"jobs/base_workers.go:83","worker":"ImportProcess","job_id":"dsxnr58hq7b97f7j8h5sugkkkc","error":"BulkImport: Channel name contains invalid characters. Can you help us to resolve this error. We will be thankful to all of you if you do this.

Hi manzoor77 and welcome to the Mattermost forums!

This message usually means that the channel names contain invalid characters. Mattermost does not allow non-latin characters in channel names, so if your slack export has some, we might need to go over them and rename them in the export file before trying to import them. You should be able to use a simple “search and replace” in your favourite text editor.

1 Like

@agriesser really appreciated your quick response. I checked my exported file but there is no non-letin character in our slack channel list that we want to export to mattermost. Can you give any other solution of this error?

@agriesser The solution mentioned regarding passwords helped us a lot with solving the issue and we were able to successfully set passwords with the code mentioned.

We worked with dummy data earlier, and have now moved to a larger export file. However, we are facing issues in the steps after this. The following error is showing up when performing the import with emails (no attachments). The “simpleworker: job execution error” shows up in the log like it did for us before, albeit with a different error: "BulkImport: Channel name contains invalid characters.”. Could it be that mattermost has some sort of constraints/limitations regarding channel characters or could this be an error log that doesn’t represent the actual error like before: Error”: “We could not count the users.“, in slack to mattermost migration - #5 by plusmid

The log is as follows:

"timestamp":"2022-09-15 19:29:33.583 Z","level":"error","msg":"SimpleWorker: job execution error","caller":"jobs/base_workers.go:83","worker":"ImportProcess","job_id":"dsxnr58hq7b97f7j8h5sugkkkc","error":"BulkImport: Channel name contains invalid characters.”

Yes, the channel names need to consist only of latin characters as far as I know; there are some channel names that are invalid.
You could use the following command to get a list of all channels and validate them against a set of allowed characters. I’m not 100% sure if any additional characters are allowed, but these are definitely allowed, so let’s run this first and see what is being printed as a result:

sed -n 's/^{"type":"channel".*"name":"\([^"]\+\)".*/\1/p' mattermost_import.jsonl | egrep -i [^-abcdefghijklmnopqrstuvwxyz0123456789_]
1 Like

@agriesser We have tried running this command but are unsure as to what output we are supposed to refer to after execution. Furthermore, there does not seem to be a file generated as a result either

If there is no output, it means that there are no channels with invalid names, at least as far as I can tell.
This command would output channel names (one per line) that do not consist solely of the characters in the map at the end, so to verify that it’s working and to see all your channel names, you can just run the following command (extracting names without the filter):

sed -n 's/^{"type":"channel".*"name":"\([^"]\+\)".*/\1/p' mattermost_import.jsonl

You should see a list of your channels to be imported now.

@plusmid created a mmctl version which supports an additional import validator functionality, this might be helpful here too.

 $ ./mmctl import validate --help
Validate an import file

  mmctl import validate [filepath] [flags]

  import validate

  -h, --help               help for validate
      --team stringArray   Predefined teams

Please give it a try with your file, it might also tell us if there are problems with the channel names.

hi @agriesser
We have tried running the command you have mentioned: sed -n ‘s/^{“type”:“channel”.“name”:“([^”]+)"./\1/p’ mattermost_import.jsonl and as a result we are getting these channels as output. However, this is not the complete list of channels on our slack workspace. The screenshot shows the channels in our output.

Moreover, upon examining the output from the ./mmetl transform slack --team invozone --file --output mattermost_import.jsonl command, we have found that there are some errors while importing messages and channels, and some errors even mention type not supported

Please once look the attachments giving the status of errors while retrieving.