slackapi / python-slack-events-api

Slack Events API adapter for Python (Flask required)
https://api.slack.com/events
MIT License
343 stars 116 forks source link

SlackEventAdapter object creates even if the signing_secret parameter gets NoneType argument #90

Closed temurchichua closed 3 years ago

temurchichua commented 3 years ago

Description

I've set the env. variable for the Slack Event Token and used it to create Adapter as following:

slack_event_adapter = SlackEventAdapter(os.environ.get("SLACK_EVENTS_TOKEN"), "/slack/events", app)

I made a typo while setting the variable, thus I was getting "Your URL didn't respond with the value of the challenge parameter." on the Event Subscription page with the following error in my terminal:

Traceback (most recent call last):
  File "D:\PycharmProjects\Slackbot\flipper\venv\lib\site-packages\flask\app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "D:\PycharmProjects\Slackbot\flipper\venv\lib\site-packages\flask\app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "D:\PycharmProjects\Slackbot\flipper\venv\lib\site-packages\flask\app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "D:\PycharmProjects\Slackbot\flipper\venv\lib\site-packages\flask\_compat.py", line 39, in reraise
    raise value
  File "D:\PycharmProjects\Slackbot\flipper\venv\lib\site-packages\flask\app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "D:\PycharmProjects\Slackbot\flipper\venv\lib\site-packages\flask\app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "D:\PycharmProjects\Slackbot\flipper\venv\lib\site-packages\slackeventsapi\server.py", line 100, in event
    if req_signature is None or not self.verify_signature(req_timestamp, req_signature):
  File "D:\PycharmProjects\Slackbot\flipper\venv\lib\site-packages\slackeventsapi\server.py", line 60, in verify_signature
    str.encode(self.signing_secret),
TypeError: descriptor 'encode' for 'str' objects doesn't apply to a 'NoneType' object

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

Requirements

Bug Report

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

Reproducible in:

slackeventsapi version: 2.2.1 python version: 3.8.6 OS version(s): Windows 10

Steps to reproduce:

  1. Create SlackEventAdapter object with NoneType value as a signing_secret parameter.
  2. Try an event subscription for your app.

Expected result:

Get the error that I've used the wrong value while creating the slack_event_adapter object

Actual result:

I got an error which was confusing at first and took some time to research

Attachments:

Logs, screenshots, screencasts, sample projects, funny gifs, etc.

seratch commented 3 years ago

Fixed by #91