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

AttributeError: 'SlackBackend' object has no attribute '_people' #409

Closed
codingmaths opened this issue Apr 11, 2019 · 9 comments
Closed

Comments

@codingmaths
Copy link

I am able to connect will with our slack channel, but when I try to chat from my slack channel, I am not getting any response from Will.

** Log **
[DEBUG] https://slack.com:443 "POST /api/rtm.start HTTP/1.1" 200 None

** Will plugin for bonjour **

from will.plugin import WillPlugin
from will.decorators import respond_to, periodic, hear, randomly, route, rendered_template, require_settings

class BonjourPlugin(WillPlugin):

@respond_to("bonjour")
def say_bonjour_will(self, message):
    """bonjour: I know how to say bonjour! In French!"""
    self.reply("bonjour!")

** Slack command **

@lazypanda bonjour

WILL_HANDLE = "lazypanda"

our slack workspace have more than 20K users, not sure if that is the issue.

@rsalmond
Copy link
Collaborator

Hey @codingmaths is that the entirety of the log? Could you try restarting Will and capturing everything from bootup to you sending a hello command in a gist and link it here?

@rsalmond rsalmond reopened this Apr 11, 2019
@rsalmond
Copy link
Collaborator

Whoops, didn't mean to close this!

@codingmaths
Copy link
Author

@rsalmond I have resolved this issue by using rtm_connect instead of rtm_start , I have changed slack client.py and server.py for same.

Now I am getting below error when I try to run command on slack

``

[DEBUG] https://slack.com:443 "POST /api/rtm.connect HTTP/1.1" 200 281
Traceback (most recent call last):
File "/Users/s0m02l2/Git/lazypanda/willbot/.willbot/lib/python2.7/site-packages/will/backends/io_adapters/base.py", line 43, in handle_incoming_event
m = self.normalize_incoming_event(event)
File "/Users/s0m02l2/Git/lazypanda/willbot/.willbot/lib/python2.7/site-packages/will/backends/io_adapters/slack.py", line 82, in normalize_incoming_event
sender = self.people[event["user"]]
File "/Users/s0m02l2/Git/lazypanda/willbot/.willbot/lib/python2.7/site-packages/will/backends/io_adapters/slack.py", line 380, in people
return self._people
AttributeError: 'SlackBackend' object has no attribute '_people'
``

@codingmaths codingmaths changed the title Not getting Slack response AttributeError: 'SlackBackend' object has no attribute '_people' Apr 12, 2019
@rsalmond
Copy link
Collaborator

I have resolved this issue by using rtm_connect instead of rtm_start , I have changed slack client.py and server.py for same

Those files are not familiar to me. Do you mean you modified the slack client itself?

AttributeError: 'SlackBackend' object has no attribute '_people'

It seems like there may be a case where this can occur if the client has not yet connected to the server.

If possible could you capture the complete Will log from startup time till the exception occurs and paste it into a gist and share the link here?

@codingmaths
Copy link
Author

codingmaths commented Apr 12, 2019

@rsalmond I have added my startup log to
Gist

I am able to connect to my slack and getting 200 response as well.

@codingmaths
Copy link
Author

codingmaths commented Apr 12, 2019

what should be the config.py configuration for slack backend. I am using :

SLACK_API_TOKEN = "XXXXxXXXXXXXX"
SLACK_DEFAULT_CHANNEL = "sre-bot"

do we need to add user details as well, in config.py

@rsalmond
Copy link
Collaborator

Hey @codingmaths thanks for the gist that helps. It looks like both the error you see there and the exception you posted earlier are related to the Slack IO adapter having not updated the people dict. That said it appears that between the exception and the gist the line sender = self.people[event["user"]] moved from line 82 to line 83.

If you want to fork Will to work on it we would be happy to help review your code, but trying to triage an issue on a modified Will using a modified Slack client without source is going to be extremely difficult. If you can document the issue using the stock Slack client and the latest stable release of Will then we can try to replicate the issue and work with you to fix it.

As far as the user details go you should be able to configure those in the Slack UI.

@codingmaths
Copy link
Author

@rsalmond . I think rtm.connect won't work with willbot , since bot also need channel details while connecting with slack. but with rta.connect we don't get that detail. please refer slack_rtm .

Now I have removed all the code changes which I have done and using default config. also using rtm.start to connect slack workspace.

here is my observation:

I am getting none response after authenticating with my slack workspace.
When I tried same code with smaller slack workspace, it’s working as expected. With more troubleshoot I got to know it’s some kind of issue with large slack workspace , when they use rtm.start.

with my experience I am able to authenticate app with slack but after that I am not getting any response from slack app. Instead I am getting none.

Please refer below log for same:

DEBUG errbot.bootstrap Start serving commands from the slack backend.
23:22:12 INFO errbot.backends.slack Verifying authentication token 23:22:12 DEBUG urllib3.connectionpool Starting new HTTPS connection (1): slack.com:443
`23:22:13 DEBUG urllib3.connectionpool https://slack.com:443 "POST /api/auth.test HTTP/1.1" 200 146. ## successfully authenticated

23:22:13 DEBUG errbot.backends.slack Token accepted 23:22:13 INFO errbot.backends.slack Connecting to Slack real-time-messaging API
23:22:13 DEBUG urllib3.connectionpool Starting new HTTPS connection (1): slack.com:443 23:22:35 DEBUG urllib3.connectionpool https://slack.com:443 "POST /api/rtm.start HTTP/1.1" 200 None. ## Getting none response

23:22:48 DEBUG root RTM connected

let me know , if you need further details.

@Ashex
Copy link
Collaborator

Ashex commented Mar 18, 2021

Closing out as we'll be using the events api per #428
If you encounter this when 2.2.0 is released please open a new issue with details.

@Ashex Ashex closed this as completed Mar 18, 2021
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

No branches or pull requests

3 participants