errbotio / errbot

Errbot is a chatbot, a daemon that connects to your favorite chat service and bring your tools and some fun into the conversation.
http://errbot.io
GNU General Public License v3.0
3.12k stars 614 forks source link

Repo install command fails with "Unparseable slack ID" #622

Closed jasedit closed 8 years ago

jasedit commented 8 years ago

Using Python 3.5, and the latest errbot from master. When I send the command:

!repos install hhttps://github.com/jasedit/errbot-catfacts.git

errbot reports the following error:

10:02:45 ERROR    errbot.backends.slack     message event handler raised an exception
Traceback (most recent call last):
  File "/Users/jpz/Projects/errbot2/lib/python3.5/site-packages/errbot/backends/slack.py", line 265, in _dispatch_slack_message
    event_handler(message)
  File "/Users/jpz/Projects/errbot2/lib/python3.5/site-packages/errbot/backends/slack.py", line 342, in _message_event_handler
    mentioned.append(self.build_identifier(word.replace(':', '')))
  File "/Users/jpz/Projects/errbot2/lib/python3.5/site-packages/errbot/backends/slack.py", line 565, in build_identifier
    username, userid, channelname, channelid = self.extract_identifiers_from_string(txtrep)
  File "/Users/jpz/Projects/errbot2/lib/python3.5/site-packages/errbot/backends/slack.py", line 543, in extract_identifiers_from_string
    raise ValueError(exception_message % text)
ValueError: Unparseable slack ID, should start with U, B, C, G or D (got `ttps//github.com/jasedit/errbot-catfacts.git`)
zoni commented 8 years ago

If I had to guess, this is a direct result of #564. Lets try and get this fixed for the upcoming 4.0 release too.

@jasedit could you by any chance do me a small favor and see if the PyPI release (3.2.3) has this issue as well?

gbin commented 8 years ago

@jasedit thanks to the brave soul testing master !

jasedit commented 8 years ago

Using the 3.2.3 release fails to connect to Slack, which is what drove me to master in the first place. The error using the result from PyPi is:

14:06:54 ERROR    errbot.backends.base      Exception occurred in serve_once:
Traceback (most recent call last):
  File "/Users/jpz/Projects/errbot2/lib/python3.5/site-packages/errbot/backends/base.py", line 620, in serve_forever
    if self.serve_once():
  File "/Users/jpz/Projects/errbot2/lib/python3.5/site-packages/errbot/backends/slack.py", line 214, in serve_once
    self.auth = self.api_call("auth.test", raise_errors=False)
  File "/Users/jpz/Projects/errbot2/lib/python3.5/site-packages/errbot/backends/slack.py", line 203, in api_call
    response = json.loads(self.sc.server.api_call(method, **data).decode('utf-8'))
AttributeError: 'str' object has no attribute 'decode'
zoni commented 8 years ago

Using the 3.2.3 release fails to connect to Slack, which is what drove me to master in the first place.

Well that really sucks. :disappointed: I'm going to get this fixed for you ASAP!

jasedit commented 8 years ago

I certainly don't understand the code fully to understand if this fix is correct, but the error in 3.2.3 is resolved if the .decode('utf-8') is removed from line 203 of slack.py. I don't know if api_call is expected to return a Unicode string instead of a plain string, or if there's something else going on, but that makes the connection succeed for me.

If preferred (and I'm not completely off in the weeds), I can submit a PR to the 3.2 branch for review with that fix. I don't know what the preferred process for such things is, so I'm happy to help or cheer as need be.

zoni commented 8 years ago

It was a little messier than that and we were dealing with two issues here.

First of all, the second issue you encountered, the one on 3.2.3:

14:06:54 ERROR    errbot.backends.base      Exception occurred in serve_once:
Traceback (most recent call last):
  File "/Users/jpz/Projects/errbot2/lib/python3.5/site-packages/errbot/backends/base.py", line 620, in serve_forever
    if self.serve_once():
  File "/Users/jpz/Projects/errbot2/lib/python3.5/site-packages/errbot/backends/slack.py", line 214, in serve_once
    self.auth = self.api_call("auth.test", raise_errors=False)
  File "/Users/jpz/Projects/errbot2/lib/python3.5/site-packages/errbot/backends/slack.py", line 203, in api_call
    response = json.loads(self.sc.server.api_call(method, **data).decode('utf-8'))
AttributeError: 'str' object has no attribute 'decode'

This was caused by Slackclient introducing a backward-incompatible change in their latest release (1.0.0). This is now fixed on master by 91e8c079db98245a2eeb2fd42117ab1250305a98 and backported to the 3.2 branch as well, just in case we end up making another 3.2.x release.

As a workaround for other people reading this bug and hitting the same issue, you can take a git checkout of either 3.2 or master branch or, alternatively, downgrade slackclient to 0.17.

As for the original issue you encountered, this has been fixed in fa6b9a4c03b48cf39a439165ca8b626a171b3b66. The callback_mention doesn't appear to be in 3.2 so people downgrading slackclient to 0.17 should have no issues with that release.

jasedit commented 8 years ago

I can confirm that updating to include the fix in fa6b9a4 fixes operating my chatbot with the master release. I haven't tested the 3.2 branch on GitHub, but it sounds like a 4.0 release is in the pipeline. Thanks for the fast and detailed responses!