Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mattermost Commands not working #291

Open
Phill93 opened this issue Dec 5, 2023 · 5 comments
Open

Mattermost Commands not working #291

Phill93 opened this issue Dec 5, 2023 · 5 comments

Comments

@Phill93
Copy link

Phill93 commented Dec 5, 2023

Environment

  • Python version: 3.9.2
  • Nautobot version: 2.0.5
  • nautobot-chatops version: 3.0.1
  • Mattermost version: 7.8.0

Expected Behavior

Working commands in Mattermost

Observed Behavior

Every time I send a command in Mattermost towards Nautobot I get the message "Command with a trigger of 'nautobot' returned response 500 Internal Server Error". The following messages can be found in the Nautobot log at DEBUG level:

Dez 05 14:57:30 netdoc nautobot-server[70872]: 14:57:30.621 ERROR   django.request :
Dez 05 14:57:30 netdoc nautobot-server[70872]:   Internal Server Error: /api/plugins/chatops/mattermost/slash_command/
Dez 05 14:57:30 netdoc nautobot-server[70872]: Traceback (most recent call last):
Dez 05 14:57:30 netdoc nautobot-server[70872]:   File "/srv/nautobot/venv/lib/python3.9/site-packages/nautobot_chatops/dispatchers/mattermost.py", line 78, in inner
Dez 05 14:57:30 netdoc nautobot-server[70872]:     return function(*args, **kwargs)
Dez 05 14:57:30 netdoc nautobot-server[70872]:   File "/srv/nautobot/venv/lib/python3.9/site-packages/nautobot_chatops/dispatchers/mattermost.py", line 143, in post
Dez 05 14:57:30 netdoc nautobot-server[70872]:     mm_response.raise_for_status()
Dez 05 14:57:30 netdoc nautobot-server[70872]:   File "/srv/nautobot/venv/lib/python3.9/site-packages/requests/models.py", line 960, in raise_for_status
Dez 05 14:57:30 netdoc nautobot-server[70872]:     raise HTTPError(http_error_msg, response=self)
Dez 05 14:57:30 netdoc nautobot-server[70872]: requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://mattermost.<redacted>/api/v4/users/me/typing
Dez 05 14:57:30 netdoc nautobot-server[70872]: During handling of the above exception, another exception occurred:
Dez 05 14:57:30 netdoc nautobot-server[70872]: Traceback (most recent call last):
Dez 05 14:57:30 netdoc nautobot-server[70872]:   File "/srv/nautobot/venv/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
Dez 05 14:57:30 netdoc nautobot-server[70872]:     response = get_response(request)
Dez 05 14:57:30 netdoc nautobot-server[70872]:   File "/srv/nautobot/venv/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response
Dez 05 14:57:30 netdoc nautobot-server[70872]:     response = wrapped_callback(request, *callback_args, **callback_kwargs)
Dez 05 14:57:30 netdoc nautobot-server[70872]:   File "/srv/nautobot/venv/lib/python3.9/site-packages/django/views/generic/base.py", line 70, in view
Dez 05 14:57:30 netdoc nautobot-server[70872]:     return self.dispatch(request, *args, **kwargs)
Dez 05 14:57:30 netdoc nautobot-server[70872]:   File "/srv/nautobot/venv/lib/python3.9/site-packages/django/utils/decorators.py", line 43, in _wrapper
Dez 05 14:57:30 netdoc nautobot-server[70872]:     return bound_method(*args, **kwargs)
Dez 05 14:57:30 netdoc nautobot-server[70872]:   File "/srv/nautobot/venv/lib/python3.9/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
Dez 05 14:57:30 netdoc nautobot-server[70872]:     return view_func(*args, **kwargs)
Dez 05 14:57:30 netdoc nautobot-server[70872]:   File "/srv/nautobot/venv/lib/python3.9/site-packages/django/views/generic/base.py", line 98, in dispatch
Dez 05 14:57:30 netdoc nautobot-server[70872]:     return handler(request, *args, **kwargs)
Dez 05 14:57:30 netdoc nautobot-server[70872]:   File "/srv/nautobot/venv/lib/python3.9/site-packages/nautobot_chatops/api/views/mattermost.py", line 114, in post
Dez 05 14:57:30 netdoc nautobot-server[70872]:     MattermostDispatcher(context).send_busy_indicator()
Dez 05 14:57:30 netdoc nautobot-server[70872]:   File "/srv/nautobot/venv/lib/python3.9/site-packages/nautobot_chatops/dispatchers/mattermost.py", line 458, in send_busy_indicator
Dez 05 14:57:30 netdoc nautobot-server[70872]:     self.mm_client.post("/users/me/typing", data={"channel_id": self.context.get("channel_id")})
Dez 05 14:57:30 netdoc nautobot-server[70872]:   File "/srv/nautobot/venv/lib/python3.9/site-packages/nautobot_chatops/dispatchers/mattermost.py", line 89, in inner
Dez 05 14:57:30 netdoc nautobot-server[70872]:     raise NotFoundException(f"Attempting to access an endpoint that does not exist: {err.response.text}")
Dez 05 14:57:30 netdoc nautobot-server[70872]: nautobot_chatops.dispatchers.mattermost.NotFoundException: Attempting to access an endpoint that does not exist: {"id":"api.context.404.app_error","message":"Sorry, we could not find the page.","detailed_error":"There doesn't appear to be an api call for the url='/api/v4/users/me/typing'.  Typo? are you missing a team_id or user_id as part of the url?","status_code":404}
Dez 05 14:57:30 netdoc nautobot-server[70872]: [pid: 70872|app: 0|req: 7/7] 127.0.0.1 () {48 vars in 779 bytes} [Tue Dec  5 14:57:30 2023] POST /api/plugins/chatops/mattermost/slash_command/ => generated 36891 bytes in 41 msecs (HTTP/1.0 500) 6 headers in 210 bytes (1 switches on core 0)

Steps to Reproduce

  1. Setup Plugin
  2. Send Command over Mattermost
@smk4664
Copy link
Contributor

smk4664 commented Dec 5, 2023

Would you mind double-checking the docs for Mattermost Setup. I believe there might be an issue with the permissions on the Bot Account. https://docs.nautobot.com/projects/chatops/en/latest/admin/install/mattermost_setup/#mattermost-setup

@Phill93
Copy link
Author

Phill93 commented Dec 5, 2023

Bildschirmfoto 2023-12-05 um 15 44 50

This are the Settings for the Mattermost Bot Account

@snaselj
Copy link
Contributor

snaselj commented Dec 5, 2023

@Phill93
Copy link
Author

Phill93 commented Dec 5, 2023

I have no development environment in which I could use the Invoke command, the problem occurs in production

@smk4664
Copy link
Contributor

smk4664 commented Dec 6, 2023

@Phill93 This could also be due to an issue authenticating to Mattermost. It could be possible that the Celery Worker is not able to access the config. This could happen if you are using Environment Variables, but only have the Environment Variables on the Nautobot service, and not the Nautobot Worker. Alternatively, the token might be wrong. You can regenerate the token in Mattermost and copy it back into the config, if you do regenerate the code, make sure you copy it on the pop-up box that appears, once you close it only the id is shown in Mattermost, not the token itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants