[Solved] Mmctl user delete fails, --json ignored,

Summary
Deleting a user with mmctl does’nt work as expected, gives strange error message

Steps to reproduce
Here is my environment:

root@border:/opt/mattermost/bin# ./mmctl --local version 
mmctl:
Version:	10.0.0
BuiltDate:	dev
CommitDate:	2024-09-02T17:54:14Z
GitCommit:	2d83d21388f3111bffe4b1f63521b21d77ec2cef
GitTreeState:	dirty
GoVersion:	go1.21.8
Compiler:	gc
Platform:	amd64/linux

First, verify User Deletion via API is allowed:

root@border:/opt/mattermost/bin# ./mmctl --local config get ServiceSettings.EnableAPIUserDeletion
true

These are (some) of my users:

root@border:/opt/mattermost/bin# ./mmctl --local user list

hxp8riz8btroiqugi6ydxxggdc: 4d (4d@localhost)
19j45bi4atnjzykxcbe5ssg19h: appsbot (appsbot@localhost)
yitihxn65fynpxaz8bfu87brzh: boards (boards@localhost)
spf5quyufjryff9byq1u8j9czo: calls (calls@localhost)
[...]
kprpod6nstyj7fe5jed1ybjx7w: testuser (testuser@mydomain.de)

There are 18 users on local instance

When I try to remove the testuser, I issue

root@border:/opt/mattermost/bin# ./mmctl --local user delete testuser@mydomain.de --confirm

Unable to delete user 'testuser' error: failed to decode JSON payload into AppError. Body: <!DOCTYPE html><html><head></head>
<body onload="window.location = '/chat/error?message\u003DWe+encountered+an+error+finding+the+account.
\u0026s\u003DMEUCIDgRWRgvRqVe2_v4Es7JpBUEl7HvFWEC3kJDfLigfs-8AiEAlAJC35i1xDHBFw7O5AvjUt0R7HbCPdYl9sucPAKnXhw\u003D'">
<noscript><meta http-equiv="refresh" content="0; url=/chat/error?message=We+encountered+an+error+finding+the+account.&amp;s=MEUCIDgRWRgvRqVe2_v4Es7JpBUEl7HvFWEC3kJDfLigfs-8AiEAlAJC35i1xDHBFw7O5AvjUt0R7HbCPdYl9sucPAKnXhw="></noscript>
<!-- web error message -->
<a href="/chat/error?message=We+encountered+an+error+finding+the+account.&amp;s=MEUCIDgRWRgvRqVe2_v4Es7JpBUEl7HvFWEC3kJDfLigfs-8AiEAlAJC35i1xDHBFw7O5AvjUt0R7HbCPdYl9sucPAKnXhw=" style="color: #c0c0c0;">...</a>
</body>
</html>
: invalid character '<' looking for beginning of value

The special points of interest are

  • failed to decode JSON payload into AppError
  • strange formatted HTML code

Requesting JSON Output does not change anything:

root@border:/opt/mattermost/bin# ./mmctl --local --json user delete testuser@mydomain.de --confirm

Same strange error message

Expected behavior
The user should be deleted

Observed behavior
User is not deleted, --json switch inoperative, strange HTML output.

Hi @SigPam, thanks for sharing the details! It looks like the error you’re encountering might be related to the way the request is being handled by the server. I’d recommend reviewing our documentation on mmctl user commands, as well as ensuring that the ServiceSettings.SiteURL is correctly configured, as it may be causing issues with your API requests. Let us know how it goes!

Hi John,

thank you for looking at this.

The SiteURL is configured correctly - at least that’s what I would claim it to be. The URL can be reached and the Mattermost server responds to requests on that, both via Web and Windows desktop client.

Reviewing mmctl user commands does not bring any new knowledge. The documentation for mmctl user delete proves my command to be valid - as long as I do not miss something very fundamentally

But I found something new and very strange: the user list differs from using --local or being logged in using mmctl auth login:

mattermost@border:~/bin$ ./mmctl --local user list | grep "There are" 
There are 18 users on local instance

mattermost@border:~/bin$ ./mmctl  user list | grep "There are" 
WARNING: server version 9.2.3.6961628977.35c8f515980a06a386a0606e9e7e7749.false doesn't match mmctl version 10.0.0
There are 16 users on https://intern.mydomain.de/chat/

Most interestingly (and a probable cause for the issue): the mismatch between the versions of mmctl and mattermost - see the warning message when accessing the server remotely.

But I installed the version 10 tarball! It seems as if the tarballs have a mismatch between mattermost and mmctl. I downgraded to 9.5.10, and I still got the same error message.

Comparing the hashes of mattermost versions 9.5.10, 9.11.2 and 10.0.0 shows differences:

(python-venv) root@border:/tmp# md5sum mattermost-upgrade-*/bin/mattermost 
03dab6275430986b7e383efc4c071f3f  mattermost-upgrade-10.0.0/bin/mattermost
baceddcee9f3aaf49a9e4e7b78364211  mattermost-upgrade-9.11.2/bin/mattermost
14d57190c3a5391748eca930c9c733bf  mattermost-upgrade-9.5.10/bin/mattermost

This means, the binaries differ. But they all claim to be a server version 9.2.3. I will now try to find an old 9.2.3 version of the server to install …

I downloaded and installed version 9.2.3, but no change. However, at least the error message telling about a version mismatch between mmctl and mattermost disappeard.

I wonder what’s so special about the accounts that they are shown with the --local option, but not when with a remote access.

You can find any version of Mattermost here: Version archive - Mattermost documentation

But I would suggest being careful in changing versions, especially down. 9.2.3 is old. I’d strongly recommend using the upgrade instructions Upgrade Mattermost Server - Mattermost documentation You may have inadvertently poisoned something somewhere.

There are different versions of mmctl for each version of Mattermost. If they don’t match, odd things can happen!

1 Like

Yeah, I think I somewhere in past screwed it up.I did a fresh install of 9.5.11 which worked fine, as well as after upgrading the fresh install to 10.1.1.

I will discard my current installation and start from scratch.

Thank you for your support.