monzo / response

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

fixed No user found then Slack API paginates #197

Open potapum opened 4 years ago

potapum commented 4 years ago

If Slack workspace contains more than 1000 user, "users.list" API call response will be paginated. users_list function did not accounted for this. If INCIDENT_BOT_NAME username is not on first page, application will throw


  File "manage.py", line 21, in <module>
    main()
  File "manage.py", line 17, in main
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 345, in execute
    settings.INSTALLED_APPS
  File "/usr/local/lib/python3.7/site-packages/django/conf/__init__.py", line 76, in __getattr__
    self._setup(name)
  File "/usr/local/lib/python3.7/site-packages/django/conf/__init__.py", line 63, in _setup
    self._wrapped = Settings(settings_module)
  File "/usr/local/lib/python3.7/site-packages/django/conf/__init__.py", line 142, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/opt/project/myincidentresponse/settings.py", line 185, in <module>
    INCIDENT_BOT_NAME
  File "/usr/local/lib/python3.7/site-packages/response/slack/client.py", line 79, in get_user_id
    raise SlackError(f"User '{name}' not found")
response.slack.client.SlackError: User '<userbame>' not found```
potapum commented 4 years ago

Hello @mattrco, Could you take a look at this PR?

alanakirby commented 3 years ago

Hi we had the same issue. Would been for you to merge this and it works with ours too.

alanakirby commented 3 years ago

@ChrisAnn @evnsio @milesbxf Any ideas when this can be merged? Need it in the module