Playbooks: Can't start new runs

Troubleshooting Mattermost Playbook Runs: Ensuring Playbooks Bot User is Active

In Mattermost, Playbooks are a powerful tool for automating workflows, incident management, and collaboration. However, one issue users may encounter is that playbooks are not able to be run. A typical cause for this is the Playbooks Bot user being deactivated or deleted, which is essential for the successful execution of playbooks.

The Mattermost Server logs should have a log message that should look similar to the following:

{
    "timestamp": "2024-09-09 19:13:08.218 Z",
    "level": "error",
    "msg": "An internal error has occurred. Check app server logs for details.",
    "caller": "app/plugin_api.go:1011",
    "plugin_id": "playbooks",
    "request_id": "xxx",
    "error": "AddChannelMember: Unable to add the user as a member of the channel.
              failed to add bot to the channel
              github.com/mattermost/mattermost-plugin-playbooks/server/app.(*PlaybookRunServiceImpl).addPlaybookRunInitialMemberships
              github.com/mattermost/mattermost-plugin-playbooks/server/app/playbook_run_service.go:2417
              github.com/mattermost/mattermost-plugin-playbooks/server/app.(*PlaybookRunServiceImpl).CreatePlaybookRun
              github.com/mattermost/mattermost-plugin-playbooks/server/app/playbook_run_service.go:328
              github.com/mattermost/mattermost-plugin-playbooks/server/api.(*PlaybookRunHandler).createPlaybookRun
              github.com/mattermost/mattermost-plugin-playbooks/server/api/playbook_runs.go:518
              github.com/mattermost/mattermost-plugin-playbooks/server/api.(*PlaybookRunHandler).createPlaybookRunFromPost
              github.com/mattermost/mattermost-plugin-playbooks/server/api/playbook_runs.go:166
              github.com/mattermost/mattermost-plugin-playbooks/server/api.NewPlaybookRunHandler.withContext.func2
              github.com/mattermost/mattermost-plugin-playbooks/server/api/context.go:36
              net/http.HandlerFunc.ServeHTTP
              net/http/server.go:2136
              main.(*Plugin).OnActivate.(*Plugin).getErrorCounterHandler.func5.1
              github.com/mattermost/mattermost-plugin-playbooks/server/plugin.go:409
              net/http.HandlerFunc.ServeHTTP
              net/http/server.go:2136
              github.com/mattermost/mattermost-plugin-playbooks/server/api.MattermostAuthorizationRequired.func1
              github.com/mattermost/mattermost-plugin-playbooks/server/api/api.go:109
              net/http.HandlerFunc.ServeHTTP
              net/http/server.go:2136
              github.com/mattermost/mattermost-plugin-playbooks/server/api.LogRequest.func1
              github.com/mattermost/mattermost-plugin-playbooks/server/api/logger.go:46
              net/http.HandlerFunc.ServeHTTP
              net/http/server.go:2136
              github.com/gorilla/mux.(*Router).ServeHTTP
              github.com/gorilla/mux@v1.8.0/mux.go:210
              github.com/mattermost/mattermost-plugin-playbooks/server/api.(*Handler).ServeHTTP
              github.com/mattermost/mattermost-plugin-playbooks/server/api/api.go:60
              main.(*Plugin).ServeHTTP
              github.com/mattermost/mattermost-p...",
    "plugin_caller": "github.com/mattermost/mattermost-plugin-playbooks/server/api/api.go:85"
}

 

This article will guide you through troubleshooting playbook run issues by checking the status of the Playbooks Bot user using a SQL query.

Why the Playbooks Bot User is Important

The Playbooks Bot user is responsible for managing and running automated playbook tasks and ensuring they execute properly. If this bot is disabled or deleted, playbook tasks may not function as expected, resulting in errors or failures in playbook execution.

To verify the status of the Playbooks Bot user, you can use a SQL query on your Mattermost database. This query will help you determine if the bot user has been accidentally deactivated or deleted.

SQL Query for Checking Playbooks Bot User Status

To check the status of the Playbooks Bot user, you can use the following SQL query:

SELECT users.id, users.username, users.deleteat AS user_delete, bots.deleteat AS bot_delete 
FROM bots 
JOIN users ON users.id = bots.userid 
WHERE users.id='botuserid';

Query Breakdown:

  • users.id: The unique ID of the user (in this case, the bot user).
  • users.username: The username associated with the user account.
  • users.deleteat: A timestamp indicating if and when the user account was deleted. If the value is 0, the user is active. Any other value indicates the time (in UNIX timestamp) at which the user was deleted.
  • bots.deleteat: A timestamp indicating if and when the bot account was deleted. Similarly, 0 means the bot is active, and any other value indicates when the bot account was deleted.

Important: Replacing botuserid

In the query, replace 'botuserid' with the actual ID of the Playbooks Bot user. You can retrieve this ID either from the plugin's configuration or by querying the database for a list of bot users and their corresponding id.

Example Query Result:

id username user_delete bot_delete
xyz123abc456 playbooks-bot 0 0

In this example:

  • user_delete = 0: This indicates the bot user account is active.
  • bot_delete = 0: This shows that the bot itself is not deleted and is fully operational.

If either user_delete or bot_delete has a value other than 0, this indicates the bot user or the bot itself has been deleted or disabled, which could be the reason why your playbook runs are failing.

What to Do if the Bot User is Deleted or Inactive

If the query result shows that the bot user is deleted or inactive (i.e., the deleteat field has a value other than 0), you can:

  1. Reactivate the Bot: If the bot user was deactivated, you can reactivate it using mmctl:
    mmctl user activate playbooks
  2. Recreate the Bot: If the bot user is completely deleted and cannot be reactivated, you may need to recreate the Playbooks Bot user by following the standard Mattermost procedures for setting up bot users.
  1. Check Logs: If the Playbooks Bot user is active, but playbook runs are still failing, you may need to check Mattermost logs for additional errors related to the Playbooks plugin or bot functionality.

Additional Troubleshooting Steps

  • Verify Permissions: Ensure that the Playbooks Bot user has the necessary permissions to execute playbooks and interact with the required channels.
  • Playbooks Plugin Configuration: Check the Mattermost system console to verify that the Playbooks plugin is correctly installed and configured.
  • Update Mattermost: Ensure that you are running the latest version of Mattermost and the Playbooks plugin, as updates may contain bug fixes or improvements that resolve bot-related issues.

Conclusion

If your Mattermost playbooks are not running, it's crucial to check the status of the Playbooks Bot user using the SQL query provided above. This will help you identify whether the bot user is deactivated or deleted, which is a possible cause of playbook execution issues. If the bot is inactive, follow the steps outlined in this article to reactivate or recreate the bot and ensure smooth operation of your playbooks.

For further assistance, consult the official Mattermost documentation or, if you have an active Mattermost Enterprise License, reach out to Mattermost support.

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Article is closed for comments.