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

Sync client swallows auth errors #530

Closed
4 of 9 tasks
Gastove opened this issue Oct 6, 2019 · 3 comments
Closed
4 of 9 tasks

Sync client swallows auth errors #530

Gastove opened this issue Oct 6, 2019 · 3 comments
Labels
bug M-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documented rtm-client Version: 2x
Milestone

Comments

@Gastove
Copy link

Gastove commented Oct 6, 2019

Description

When given an invalid bot token, the RTM client just... sits there. No error is raised; no output is provided that something is wrong, unless the log level is set to debug, in which case the problem becomes clearly visible:

The server responded with: {'ok': False, 'error': 'invalid_auth'}

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

Reproducible in:

slackclient version: slackclient==2.2.0

python version: 3.7.4

OS version(s): Fedora 30

Steps to reproduce:

  1. Start the RTM client with an invalid token:
rtm_client = slack.RTMClient(token="I am not a token")
rtm_client.start()

Expected result:

I should get a runtime exception of some form, indicating my token is bad.

Actual result:

The client simply runs for as long as I'll let it, with no output of any kind. If I set log level to debug, the API is clearly telling the client about the problem:

The server responded with: {'ok': False, 'error': 'invalid_auth'}
@seratch seratch added bug M-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documented rtm-client Version: 2x labels Apr 13, 2020
@seratch
Copy link
Member

seratch commented Apr 13, 2020

First of all, I'm sorry for no response here.

I just checked this issue. As of version 2.5.0, the behavior seems to be a bit different.

It immediately raises TypeError: 'NoneType' object is not subscriptable. The error information still can be improved. But at least some error happens synchronously.

from slack import RTMClient
try:
    rtm_client = RTMClient(token="I am not a token", run_async=False)
    rtm_client.start()
except Exception as e:
    print(f"*** Immediately got an Exception: {e} ***")
    raise e
finally:
    print("*** finally called ***")
>>> try:
...     rtm_client = RTMClient(token="I am not a token", run_async=False)
...     rtm_client.start()
... except Exception as e:
...     print(f"*** Immediately got an Exception: {e} ***")
...     raise e
... finally:
...     print("*** finally called ***")
... 
*** Immediately got an Exception: 'NoneType' object is not subscriptable ***
*** finally called ***

Traceback (most recent call last):
  File "/path-to-python/site-packages/slack/rtm/client.py", line 329, in _connect_and_read
    url, data = await self._retreive_websocket_info()
  File "/path-to-python/site-packages/slack/rtm/client.py", line 503, in _retreive_websocket_info
    resp = await self._web_client.rtm_connect()
  File "/path-to-python/site-packages/slack/web/base_client.py", line 226, in _send
    return SlackResponse(**{**data, **res}).validate()
  File "/path-to-python/site-packages/slack/web/slack_response.py", line 176, in validate
    raise e.SlackApiError(message=msg, response=self)
slack.errors.SlackApiError: The request to the Slack API failed.
The server responded with: {'ok': False, 'error': 'invalid_auth'}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 6, in <module>
  File "<stdin>", line 3, in <module>
  File "/path-to-python/site-packages/slack/rtm/client.py", line 198, in start
    return self._event_loop.run_until_complete(future)
  File "/path-to-python/asyncio/base_events.py", line 587, in run_until_complete
    return future.result()
  File "/path-to-python/site-packages/slack/rtm/client.py", line 356, in _connect_and_read
    await self._wait_exponentially(exception)
  File "/path-to-python/site-packages/slack/rtm/client.py", line 523, in _wait_exponentially
    wait_time = exception.response["headers"]["Retry-After"]
TypeError: 'NoneType' object is not subscriptable

@seratch seratch added this to the 2.6.0 milestone Apr 20, 2020
seratch added a commit to seratch/python-slack-sdk that referenced this issue Apr 21, 2020
seratch added a commit to seratch/python-slack-sdk that referenced this issue Apr 21, 2020
seratch added a commit to seratch/python-slack-sdk that referenced this issue Apr 27, 2020
* slackapi#530 Fixed by changing _execute_in_thread to be a coroutine
* slackapi#569 Resolved by removing a blocking loop (while future.running())
* slackapi#645 WebClient(run_async=False) no longer depends on asyncio by default
* slackapi#633 WebClient(run_async=False) doesn't internally depend on aiohttp
* slackapi#631 When run_async=True, RTM listner can be a normal function and WebClient is free from the event loop
* slackapi#630 WebClient no longer depends on aiohttp when run_async=False
* slackapi#497 Fixed when run_async=False / can be closed as we don't support run_async=True for this use case (in Flask)
seratch added a commit to seratch/python-slack-sdk that referenced this issue Apr 28, 2020
* slackapi#530 Fixed by changing _execute_in_thread to be a coroutine
* slackapi#569 Resolved by removing a blocking loop (while future.running())
* slackapi#645 WebClient(run_async=False) no longer depends on asyncio by default
* slackapi#633 WebClient(run_async=False) doesn't internally depend on aiohttp
* slackapi#631 When run_async=True, RTM listner can be a normal function and WebClient is free from the event loop
* slackapi#630 WebClient no longer depends on aiohttp when run_async=False
* slackapi#497 Fixed when run_async=False / can be closed as we don't support run_async=True for this use case (in Flask)
seratch added a commit to seratch/python-slack-sdk that referenced this issue Apr 28, 2020
* slackapi#530 Fixed by changing _execute_in_thread to be a coroutine
* slackapi#569 Resolved by removing a blocking loop (while future.running())
* slackapi#645 WebClient(run_async=False) no longer depends on asyncio by default
* slackapi#633 WebClient(run_async=False) doesn't internally depend on aiohttp
* slackapi#631 When run_async=True, RTM listner can be a normal function and WebClient is free from the event loop
* slackapi#630 WebClient no longer depends on aiohttp when run_async=False
* slackapi#497 Fixed when run_async=False / can be closed as we don't support run_async=True for this use case (in Flask)
seratch added a commit to seratch/python-slack-sdk that referenced this issue Apr 30, 2020
* slackapi#530 Fixed by changing _execute_in_thread to be a coroutine
* slackapi#569 Resolved by removing a blocking loop (while future.running())
* slackapi#645 WebClient(run_async=False) no longer depends on asyncio by default
* slackapi#633 WebClient(run_async=False) doesn't internally depend on aiohttp
* slackapi#631 When run_async=True, RTM listner can be a normal function and WebClient is free from the event loop
* slackapi#630 WebClient no longer depends on aiohttp when run_async=False
* slackapi#497 Fixed when run_async=False / can be closed as we don't support run_async=True for this use case (in Flask)
seratch added a commit to seratch/python-slack-sdk that referenced this issue May 11, 2020
* slackapi#530 Fixed by changing _execute_in_thread to be a coroutine
* slackapi#569 Resolved by removing a blocking loop (while future.running())
* slackapi#645 WebClient(run_async=False) no longer depends on asyncio by default
* slackapi#633 WebClient(run_async=False) doesn't internally depend on aiohttp
* slackapi#631 When run_async=True, RTM listner can be a normal function and WebClient is free from the event loop
* slackapi#630 WebClient no longer depends on aiohttp when run_async=False
* slackapi#497 Fixed when run_async=False / can be closed as we don't support run_async=True for this use case (in Flask)
seratch added a commit to seratch/python-slack-sdk that referenced this issue May 11, 2020
* slackapi#530 Fixed by changing _execute_in_thread to be a coroutine
* slackapi#569 Resolved by removing a blocking loop (while future.running())
* slackapi#645 WebClient(run_async=False) no longer depends on asyncio by default
* slackapi#633 WebClient(run_async=False) doesn't internally depend on aiohttp
* slackapi#631 When run_async=True, RTM listner can be a normal function and WebClient is free from the event loop
* slackapi#630 WebClient no longer depends on aiohttp when run_async=False
* slackapi#497 Fixed when run_async=False / can be closed as we don't support run_async=True for this use case (in Flask)
seratch added a commit to seratch/python-slack-sdk that referenced this issue May 11, 2020
* slackapi#530 Fixed by changing _execute_in_thread to be a coroutine
* slackapi#569 Resolved by removing a blocking loop (while future.running())
* slackapi#645 WebClient(run_async=False) no longer depends on asyncio by default
* slackapi#633 WebClient(run_async=False) doesn't internally depend on aiohttp
* slackapi#631 When run_async=True, RTM listner can be a normal function and WebClient is free from the event loop
* slackapi#630 WebClient no longer depends on aiohttp when run_async=False
* slackapi#497 Fixed when run_async=False / can be closed as we don't support run_async=True for this use case (in Flask)
seratch added a commit to seratch/python-slack-sdk that referenced this issue May 11, 2020
* slackapi#530 Fixed by changing _execute_in_thread to be a coroutine
* slackapi#569 Resolved by removing a blocking loop (while future.running())
* slackapi#645 WebClient(run_async=False) no longer depends on asyncio by default
* slackapi#633 WebClient(run_async=False) doesn't internally depend on aiohttp
* slackapi#631 When run_async=True, RTM listner can be a normal function and WebClient is free from the event loop
* slackapi#630 WebClient no longer depends on aiohttp when run_async=False
* slackapi#497 Fixed when run_async=False / can be closed as we don't support run_async=True for this use case (in Flask)
seratch added a commit to seratch/python-slack-sdk that referenced this issue May 11, 2020
* slackapi#530 Fixed by changing _execute_in_thread to be a coroutine
* slackapi#569 Resolved by removing a blocking loop (while future.running())
* slackapi#645 WebClient(run_async=False) no longer depends on asyncio by default
* slackapi#633 WebClient(run_async=False) doesn't internally depend on aiohttp
* slackapi#631 When run_async=True, RTM listner can be a normal function and WebClient is free from the event loop
* slackapi#630 WebClient no longer depends on aiohttp when run_async=False
* slackapi#497 Fixed when run_async=False / can be closed as we don't support run_async=True for this use case (in Flask)
seratch added a commit to seratch/python-slack-sdk that referenced this issue May 11, 2020
* slackapi#530 Fixed by changing _execute_in_thread to be a coroutine
* slackapi#569 Resolved by removing a blocking loop (while future.running())
* slackapi#645 WebClient(run_async=False) no longer depends on asyncio by default
* slackapi#633 WebClient(run_async=False) doesn't internally depend on aiohttp
* slackapi#631 When run_async=True, RTM listner can be a normal function and WebClient is free from the event loop
* slackapi#630 WebClient no longer depends on aiohttp when run_async=False
* slackapi#497 Fixed when run_async=False / can be closed as we don't support run_async=True for this use case (in Flask)
seratch added a commit to seratch/python-slack-sdk that referenced this issue May 11, 2020
* slackapi#530 Fixed by changing _execute_in_thread to be a coroutine
* slackapi#569 Resolved by removing a blocking loop (while future.running())
* slackapi#645 WebClient(run_async=False) no longer depends on asyncio by default
* slackapi#633 WebClient(run_async=False) doesn't internally depend on aiohttp
* slackapi#631 When run_async=True, RTM listner can be a normal function and WebClient is free from the event loop
* slackapi#630 WebClient no longer depends on aiohttp when run_async=False
* slackapi#497 Fixed when run_async=False / can be closed as we don't support run_async=True for this use case (in Flask)
seratch added a commit to seratch/python-slack-sdk that referenced this issue May 13, 2020
* slackapi#530 Fixed by changing _execute_in_thread to be a coroutine
* slackapi#569 Resolved by removing a blocking loop (while future.running())
* slackapi#645 WebClient(run_async=False) no longer depends on asyncio by default
* slackapi#633 WebClient(run_async=False) doesn't internally depend on aiohttp
* slackapi#631 When run_async=True, RTM listner can be a normal function and WebClient is free from the event loop
* slackapi#630 WebClient no longer depends on aiohttp when run_async=False
* slackapi#497 Fixed when run_async=False / can be closed as we don't support run_async=True for this use case (in Flask)
seratch added a commit to seratch/python-slack-sdk that referenced this issue May 14, 2020
* slackapi#530 Fixed by changing _execute_in_thread to be a coroutine
* slackapi#569 Resolved by removing a blocking loop (while future.running())
* slackapi#645 WebClient(run_async=False) no longer depends on asyncio by default
* slackapi#633 WebClient(run_async=False) doesn't internally depend on aiohttp
* slackapi#631 When run_async=True, RTM listner can be a normal function and WebClient is free from the event loop
* slackapi#630 WebClient no longer depends on aiohttp when run_async=False
* slackapi#497 Fixed when run_async=False / can be closed as we don't support run_async=True for this use case (in Flask)
@seratch
Copy link
Member

seratch commented May 15, 2020

Let me close this issue now as #662 resolved it.

@seratch seratch closed this as completed May 15, 2020
@seratch
Copy link
Member

seratch commented May 15, 2020

👋 slackclient 2.6.0rc1 is out. The pre-release version contains fixes for your issue described here.
https://pypi.org/project/slackclient/2.6.0rc1/

One week later from now, we'll be releasing version 2.6.0 to PyPI.

If you have a chance, could you try the release candidate version out and let us know your feedback? Thank you very much for being patient with this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug M-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documented rtm-client Version: 2x
Projects
None yet
Development

No branches or pull requests

2 participants