No channel with ID XYZzzzzz exists
In order to let us help you better, please fill out the following fields as best you can:
I am...
- [x] Reporting a bug
- [ ] Suggesting a new feature
- [x] Requesting help with running my bot
- [ ] Requesting help writing plugins
- [ ] Here about something else
I am running...
- Errbot version: errbot-6.1.1
- Slackclient version: slackclient=1.3.1
- OS version: MacOS Mojave
- Python version: 3.6
- Using a virtual environment: yes
Issue description
I am trying to run errbot with with_team_state=False because of large team size. When I start the errbot it gives below messages:
22:15:32 ERROR errbot.backends.slack Failed to look up Slack userid for alternate prefix "@testbot": Cannot find user testbot.
When I send a message to bot its errors out following lines on terminal: raise RoomDoesNotExistError(f'No channel with ID {id_} exists.') errbot.backends.base.RoomDoesNotExistError: No channel with ID XYZzzzzz exists.
With smaller team size in a test workspace also with parameter with_team_state=False it gives the same above error message.
Steps to reproduce
-
install errbot==6.1.1 with slackclient==1.3.1 in a python 3.6 virtualenv
-
modify the file errbot/backends/slack.py as below 369 if self.sc.rtm_connect(
with_team_state=False): -
run the client, it should ERROR below message 22:15:32 ERROR errbot.backends.slack Failed to look up Slack userid for alternate prefix "@testbot": Cannot find user testbot.
-
invite the bot in your channel and send a message. It should give below error message. raise RoomDoesNotExistError(f'No channel with ID {id_} exists.') errbot.backends.base.RoomDoesNotExistError: No channel with ID XYZzzzzz exists.
Additional info
If you have any more information, please specify it here.
Would you be able to post your config.py file (remove sensitive token)?
Hi @sijis
Since I am using rtm.connect instead of rtm.start. If I add following code in slackclient/server.py which solves the problem of No channel with ID XYZzzzzz exists.
def parse_slack_login_data(self, login_data, use_rtm_start):
resp_channel = self.api_requester.do(
self.token, 'channels.list', post_data={'auto_reconnect': True}, timeout=None
)
channels = resp_channel.json()
if channels["ok"]:
self.parse_channel_data(channels['channels'])
Hi @sijis : Can you please suggest if usr_rtm_start=True then does this need to run this check,
errbot/backends/slack.py", line 556, in channelid_to_channelname
raise RoomDoesNotExistError(f'No channel with ID {id_} exists.')
It is required to convert id -> name?
@skthub did you get this fixed? we are also on a large slack environment and want to use rtm.connect, but im seeing the same errors as you.
Yes, I got slack.py patched by pulling channel and user info in errbot/backends/slack.py.. if you are using errbot 6.1.1 then you try adding below code in class SlackPerson(Person). may be a workaround but worked for me.
self.user = self._sc.server.users.get(self._userid)
# users.info
if self.user is None and self._userid:
log.info(f'Fetch user info for: {self._userid}')
args = 'users.info?user={}'.format(self._userid)
resp = self._sc.server.api_requester.do(
sc.token, args, post_data={'auto_reconnect': True}, timeout=None
)
info = resp.json()
if info['ok']:
user = info['user']
if "tz" not in user:
user["tz"] = "unknown"
if "real_name" not in user:
user["real_name"] = user["name"]
if "email" not in user["profile"]:
user["profile"]["email"] = ""
self._sc.server.attach_user(
user['name'],
user['id'],
user['real_name'],
user['tz'],
user['profile']['email'],
)
# channels.info
self.channel = self._sc.server.channels.find(self._channelid)
if self.channel is None and self._channelid:
log.info("fetching channels info for channel ID: {}".format(self._channelid))
args = 'channels.info?channel={}'.format(self._channelid)
resp = self._sc.server.api_requester.do(
sc.token, args, post_data={'auto_reconnect': True}, timeout=None
)
info = resp.json()
if info['ok']:
channel = info['channel']
if channel["members"] is None:
channel['members'] = []
self._sc.server.attach_channel(
channel['name'],
channel['id'],
channel['members'],
)
@skthub thanks, that works for me too. However, im still seeing "No channel with ID XYZzzzzz exists" when running commands from Private Slack Channels. Do you have any ideas?
For anyone else who finds this later, the private channel issue was solved by adding the below to the parse_slack_login_data function in slackclient's server.py
else:
self.id = self.login_data["self"]["id"]
channel_data = []
resp = self.api_requester.do(
self.token, 'conversations.list', post_data={'auto_reconnect': True,'types': 'private_channel','limit': '50'}, timeout=None
)
resp_data = resp.json()
channel_data.extend(resp_data['channels'])
while resp_data['response_metadata']['next_cursor']:
resp = self.api_requester.do(
self.token, 'conversations.list', post_data={'auto_reconnect': True,'types': 'private_channel','limit': '50','cursor': resp_data['response_metadata']['next_cursor']}, timeout=None
)
resp_data = resp.json()
channel_data.extend(resp_data['channels'])
resp = self.api_requester.do(
self.token, 'users.conversations', post_data={'auto_reconnect': True,'id': self.id,'limit': '50'}, timeout=None
)
resp_data = resp.json()
channel_data.extend(resp_data['channels'])
while resp_data['response_metadata']['next_cursor']:
resp = self.api_requester.do(
self.token, 'users.conversations', post_data={'auto_reconnect': True,'id': self.id,'limit': '50','cursor': resp_data['response_metadata']['next_cursor']}, timeout=None
)
resp_data = resp.json()
channel_data.extend(resp_data['channels'])
self.parse_channel_data(channel_data)
I try this solution, but cannot find userid, can ACL error is You're not allowed to access this command from this user
My team use errbotv5.2 and slackclientv1.3.1, because our slack is huge, so rtm.start is naturally more difficult to use with Enterprise Grid and other large workspaces.
After troubleshooting, we find out the bottleneck is CPU, old instance type is t3a.medium, which is often crash at errbot restart and need to wait for 6 mins to pull information from slack.
After the change to c5.large, I test 3 times restart, no crash anymore, faster to pull information from slack, only 4 mins
I have invited my bot to a private channel and was getting the error commented above. Changed the "Bot User OAuth Token" by the "User OAuth Token" and it worked! I thought it might be related to the bot not able to find channels only visible by the user.