Applies to: Mattermost Server self-hosted (v9.x and later), any plugin that provisions a bot account through the plugin bot helper; observed with the Jira plugin on PostgreSQL
Symptoms: A plugin will not activate, and the server log shows that the bot account could not be created or patched because another account already owns the bot's email address.
🛑 Problem
When a plugin activates, it calls the plugin bot helper to ensure its bot account exists. The server sets the bot user's email from the bot's username in the form <botusername>@localhost . The Users table enforces a unique constraint on the email column, so if any existing account already holds that exact address, the insert or patch is rejected at the database level and plugin activation aborts. This most often happens where a regular user account was previously created with that address by hand, or where an account was converted into a bot and the original address was left in place. Because the plugin always derives the same address, retrying activation cannot succeed until the conflicting account is changed.
Symptoms
failed to ensure bot account: failed to patch bot: PatchBot: An account with that email already exists., Emailexists jira@localhost pq: duplicate key value violates unique constraint "users_email_key" (23505)
- A plugin remains disabled and cannot be enabled from the System Console.
- The server log records a bot account creation or patch failure at activation time.
- The database reports a unique constraint violation on the users email column.
- The address in the error matches the pattern
<botusername>@localhost.
âś… Solution
Identify the existing account holding the conflicting address and change that account's email. The bot's address cannot be changed, because the plugin re-derives and reapplies it on every activation.
Step 1: Identify the conflicting account
- Search for the address named in the error.
mmctl user search jira@localhost
- If the search returns nothing useful, list all accounts and look for the address.
mmctl user list --all
- Note the username or user ID of the account that holds the address, and confirm with the account owner or with your directory that the account is no longer in active use.
Step 2: Change the conflicting account's email
- Assign a different, valid address to the conflicting account. The command takes the user first and the new address second.
mmctl user email <conflicting-username> newaddress@example.com
- Re-enable the plugin from the System Console or with mmctl. The plugin now creates or patches its bot account successfully.
⚠️ Important: Change the email on the other account, not on the bot. The plugin sets the bot's email to
<botusername>@localhoston every activation, so any change made to the bot is overwritten. Before changing the other account's address, confirm it is not still in use, because any login flow, password reset, or notification that depends on that address will be affected. Where the conflicting account is a legacy integration account you intend to keep, the documented alternative is to change its username and restart the server so the plugin can provision its own bot cleanly.
Comments
Article is closed for comments.