wee-slack: newest wee-slack broken after new user added to org

Hello,

I’ve been a daily user of wee-slack now for a little over a year. My configuration broke this last weekend on the most recent RC code in what appears to me as a user mixup/identification issue.

Fun side note, my name is Ryan Stark and another Ryan Stark was added to our org over the last couple of weeks via acquisition.

Also of note, he is logged into his company’s slack workspace and I am logged onto my company’s slack workspace. These separate slack workspaces share some common channels using a new/beta feature: https://get.slack.help/hc/en-us/articles/115004152843 I originally thought that this was a new user with the same real name provisioned in our company’s slack workspace, however that is not the case.

Here is a debug output sample from a fresh weechat-1.9.1 on FreeBSD-11.1, using wee-slack-1.0-RC1 (says 1.99 internally):

python scripts loaded: slack
Plugins loaded: alias, aspell, buflist, charset, exec, fifo, irc, logger, lua, perl, python, relay, ruby, script, tcl, trigger, xfer
python: stdout/stderr: Traceback (most recent call last):
python: stdout/stderr:   File "/usr/home/foo/.weechat/python/autoload/wee_slack.py", line 502, in handle_next
python: stdout/stderr:     EVENTROUTER.handle_next()
python: stdout/stderr:   File "/usr/home/foo/.weechat/python/autoload/wee_slack.py", line 490, in handle_next
python: stdout/stderr:     self.handlers[function_name](j, self, **kwargs)
python: stdout/stderr:   File "/usr/home/foo/.weechat/python/autoload/wee_slack.py", line 2104, in handle_rtmstart
python: stdout/stderr:     channels[item["id"]] = SlackDMChannel(eventrouter, users, **item)
python: stdout/stderr:   File "/usr/home/foo/.weechat/python/autoload/wee_slack.py", line 1596, in __init__
python: stdout/stderr:     kwargs["name"] = users[dmuser].name
python: stdout/stderr: KeyError: u'U03XXXXXX'

My Slack Community member ID is: U0CYYYYYY The ‘new’ Ryan Stark Slack Community member ID is: U03XXXXXX

I should also note that when I revert to 0.99.11 code, the plugin does function although it has it’s own errors reported:

slack: DEBUG: Loading messages from cache.
slack: DEBUG: Completed loading messages from cache.
python scripts loaded: slack_extension
Plugins loaded: alias, aspell, buflist, charset, exec, fifo, irc, logger, lua, perl, python, relay, ruby, script, tcl, trigger, xfer
python: stdout/stderr: Traceback (most recent call last):
python: stdout/stderr:   File "/usr/home/foo/.weechat/python/autoload/wee_slack.py", line 2316, in url_processor_cb
python: stdout/stderr:     servers.find(data["token"]).connected_to_slack(my_json)
python: stdout/stderr:   File "/usr/home/foo/.weechat/python/autoload/wee_slack.py", line 266, in connected_to_slack 
python: stdout/stderr:     self.create_slack_mappings(login_data)
python: stdout/stderr:   File "/usr/home/foo/.weechat/python/autoload/wee_slack.py", line 340, in create_slack_mappings
python: stdout/stderr:     self.add_channel(Channel(self, **item))
python: stdout/stderr:   File "/usr/home/foo/.weechat/python/autoload/wee_slack.py", line 190, in add_channel
python: stdout/stderr:     self.channels.append(channel, channel.get_aliases())
python: stdout/stderr:   File "/usr/home/foo/.weechat/python/autoload/wee_slack.py", line 472, in get_aliases
python: stdout/stderr:     aliases = [self.fullname(), self.name, self.identifier, self.name[1:], ]
python: stdout/stderr:   File "/usr/home/foo/.weechat/python/autoload/wee_slack.py", line 554, in fullname
python: stdout/stderr:     return "{}.{}".format(self.server.server_buffer_name, self.name)
python: stdout/stderr: UnicodeEncodeError: 'ascii' codec can't encode character u'\xf1' in position 5: ordinal not in range(128)
python: error in function "url_processor_cb"
Disconnected from slack, trying to reconnect..
.
.
.
Connected to Slack
Websocket URL        wss://XXXXXXXXXXXXXXX
User name           XXXXXX
User ID                  XXXXXX
Team name         XXXXXX
Team domain     XXXXXX
Team id                XXXXXX
python: stdout/stderr: Traceback (most recent call last):
python: stdout/stderr:   File "/usr/home/foo/.weechat/python/autoload/wee_slack.py", line 1558, in slack_websocket_cb
python: stdout/stderr:     proc[function_name](message_json)
python: stdout/stderr:   File "/usr/home/foo/.weechat/python/autoload/wee_slack.py", line 1746, in process_im_marked 
python: stdout/stderr:     channel.mark_read(False)
python: stdout/stderr: AttributeError: 'NoneType' object has no attribute 'mark_read'
python: error in function "slack_websocket_cb"
.
.
.

While the old code base does take a while with multiple Disconnected from slack, trying to reconnect.. messages, it does ultimately connect and display the proper User ID value: U0CYYYYYY.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 17 (4 by maintainers)

Most upvoted comments

I got asked about this bug by a co-worker today, so spent a few cycles setting up wee-slack on a new laptop. It appears that patch provided in #492 does get me up and running again! Avoid error on DM buffer with unknown user

--- wee_slack.py	2018-03-12 09:38:00.000000000 -0500
+++ .weechat/python/autoload/wee_slack.py	2018-03-12 11:24:39.000000000 -0500
@@ -2153,7 +2153,8 @@
             channels[item["id"]] = SlackChannel(eventrouter, **item)

         for item in login_data["ims"]:
-            channels[item["id"]] = SlackDMChannel(eventrouter, users, **item)
+            if item["user"] in users:
+                channels[item["id"]] = SlackDMChannel(eventrouter, users, **item)

         for item in login_data["groups"]:
             if item["name"].startswith('mpdm-'):

Thanks @rarbab!

To elaborate, when wee-slack starts it calls rtm.start and creates users, teams etc. from the response of that. The object storing the users for each team is never changed after that. As far as I know, users from other teams are not included in the user list from rtm.start, even if there are channels/IMs with users from other teams. However, the IDs are referenced in such channels/ims. That causes the KeyError you pasted.

I think we need to lookup those IDs when initializing the shared channels/IMs to get info about the user, and store it in the users object. I thought #462 did that, but apparently not since you still get the error. I haven’t had the time to look at that PR yet unfortunately. It might be that it only does it for shared channels, and not for shared IMs.

I was able to upgrade to weechat 2.0 today so repeated my testing and found the same results using the newest wee-slack plugin.

WeeChat 2.0 [compiled on Dec  5 2017 13:11:57]
python scripts loaded: slack
python: stdout/stderr: Traceback (most recent call last):
python: stdout/stderr:   File "/usr/home/syah/.weechat/python/autoload/wee_slack.py", line 502, in handle_next
python: stdout/stderr:     EVENTROUTER.handle_next()
python: stdout/stderr:   File "/usr/home/syah/.weechat/python/autoload/wee_slack.py", line 490, in handle_next
python: stdout/stderr:     self.handlers[function_name](j, self, **kwargs)
python: stdout/stderr:   File "/usr/home/syah/.weechat/python/autoload/wee_slack.py", line 2104, in handle_rtmstart
python: stdout/stderr:     channels[item["id"]] = SlackDMChannel(eventrouter, users, **item)
python: stdout/stderr:   File "/usr/home/syah/.weechat/python/autoload/wee_slack.py", line 1596, in __init__
python: stdout/stderr:     kwargs["name"] = users[dmuser].name
python: stdout/stderr: KeyError: u'U03XXXXXX'

output from slack-debug buffer:

DEBUG: Unexpected error: (<type 'exceptions.IOError'>, IOError(2, 'No such file or directory'), <traceback object at 0x80cc83ea8>)