monzo / response

Monzo's real-time incident response and reporting tool ⚡️
MIT License
1.52k stars 165 forks source link

Error calling Slack API endpoint 'channels.list': method_deprecated #218

Closed sjdweb closed 4 years ago

sjdweb commented 4 years ago

Have you seen this error? Mirrored the demo app, double checked the environment variables and Slack app configuration.

response    | Traceback (most recent call last):
response    |   File "manage.py", line 21, in <module>
response    |     main()
response    |   File "manage.py", line 17, in main
response    |     execute_from_command_line(sys.argv)
response    |   File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
response    |     utility.execute()
response    |   File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 325, in execute
response    |     settings.INSTALLED_APPS
response    |   File "/usr/local/lib/python3.7/site-packages/django/conf/__init__.py", line 79, in __getattr__
response    |     self._setup(name)
response    |   File "/usr/local/lib/python3.7/site-packages/django/conf/__init__.py", line 66, in _setup
response    |     self._wrapped = Settings(settings_module)
response    |   File "/usr/local/lib/python3.7/site-packages/django/conf/__init__.py", line 157, in __init__
response    |     mod = importlib.import_module(self.SETTINGS_MODULE)
response    |   File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module
response    |     return _bootstrap._gcd_import(name[level:], package, level)
response    |   File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
response    |   File "<frozen importlib._bootstrap>", line 983, in _find_and_load
response    |   File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
response    |   File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
response    |   File "<frozen importlib._bootstrap_external>", line 728, in exec_module
response    |   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
response    |   File "/app/resp/settings/dev.py", line 59, in <module>
response    |     INCIDENT_CHANNEL_NAME
response    |   File "/usr/local/lib/python3.7/site-packages/response/slack/client.py", line 100, in get_channel_id
response    |     cursor=next_cursor,
response    |   File "/usr/local/lib/python3.7/site-packages/response/slack/client.py", line 61, in api_call
response    |     slack_error=error,
response    | response.slack.client.SlackError: Error calling Slack API endpoint 'channels.list': method_deprecated
evnsio commented 4 years ago

From the API docs for channels.list, it looks like any apps created after June 10th won't have access to this method. Looks like we need to migrate to conversations.list.

image

sjdweb commented 4 years ago

Hi @evnsio thanks for confirming, we're keen to test this out so I'll have a quick go at a refactor to conversations.list and will send a PR.

sjdweb commented 4 years ago

I've submitted a PR with a fix. I've tested this end to end, main change was the conversations.join method requires the channel ID and not channel name like channel.join.

mchapple commented 4 years ago

Hey @sjdweb is there any update on who is able or willing to approve this PR?

We're looking to implement this with the new code fix to include the conversations vs channels method to circumvent. Really appreciate this effort 👍

vmattos commented 4 years ago

Same here I just (temporarily) re-implemented your code on our fork. (Thank you very much 🤙)

There are some other updates that had to be done regarding the Slack client. I'll organize them on another PR later

sjdweb commented 4 years ago

Hey. I can't speak for Monzo, but hopefully they get chance to pick these changes up.

Would advise maintaining a fork in the meantime.

mtmn commented 4 years ago

@milesbxf @evnsio could you please take a look at this when you have time? I tried implementing it Today and there's no way how to make it work unfortunately.

milesbxf commented 4 years ago

The PR has been merged and the fix should be available in response v0.5.0. Thanks so much for reporting and fixing this @sjdweb - and thanks also to @sebigavril for independently submitting a separate PR with the fix too

sjdweb commented 4 years ago

Awesome thanks @milesbxf, happy to contribute.