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

fixed No user found then Slack API paginates #197

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

potapum
Copy link

@potapum potapum commented Jan 28, 2020

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```

Added check and additional requests for paginated users.list Slack API call.
fixed wrong combining of lists
@potapum potapum marked this pull request as ready for review January 28, 2020 16:24
@potapum potapum requested a review from milesbxf January 29, 2020 06:48
fixed infinite loop in pagination
@potapum potapum requested review from ChrisAnn and evnsio January 29, 2020 13:18
@potapum
Copy link
Author

potapum commented Mar 4, 2020

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

Copy link

@sebigavril sebigavril left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had the same issue. Tested your changes and they fix it.

@alanakirby
Copy link

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

@alanakirby
Copy link

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

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

Successfully merging this pull request may close these issues.

3 participants