craigtrim / slackbot-helper

Helper Functions for Slackbots
0 stars 0 forks source link

Defect in User ID Extraction Algorithm #5

Closed craigtrim closed 1 year ago

craigtrim commented 1 year ago
Traceback (most recent call last):
  File "C:\Users\Craig\AppData\Local\pypoetry\Cache\virtualenvs\climate-bot-WzljwpJV-py3.8\lib\site-packages\slack_bolt\listener\thread_runner.py", line 120, in run_ack_function_asynchronously
    listener.run_ack_function(request=request, response=response)
  File "C:\Users\Craig\AppData\Local\pypoetry\Cache\virtualenvs\climate-bot-WzljwpJV-py3.8\lib\site-packages\slack_bolt\listener\custom_listener.py", line 50, in run_ack_function
    return self.ack_function(
  File ".\climate_bot\router.py", line 45, in app_mention
    d_event = app_mention_handler(body['event'])
  File "C:\Users\Craig\git\climate\climate-bot\climate_bot\app_mention\bp\app_mention_orchestrator.py", line 148, in handle
    d_event_normalized = normalize_event(
  File "C:\Users\Craig\AppData\Local\pypoetry\Cache\virtualenvs\climate-bot-WzljwpJV-py3.8\lib\site-packages\slackbot_helper\__init__.py", line 73, in normalize_event
    return NormalizeIncomingEvent(bot_ids).process(d_event)
  File "C:\Users\Craig\AppData\Local\pypoetry\Cache\virtualenvs\climate-bot-WzljwpJV-py3.8\lib\site-packages\slackbot_helper\core\bp\normalize_incoming_event.py", line 45, in process
    d_analyzed = self._analyze(d_transformed)
  File "C:\Users\Craig\AppData\Local\pypoetry\Cache\virtualenvs\climate-bot-WzljwpJV-py3.8\lib\site-packages\slackbot_helper\core\svc\analyze_slack_event.py", line 120, in process
    d_analyzed = self._process(d_event)
  File "C:\Users\Craig\AppData\Local\pypoetry\Cache\virtualenvs\climate-bot-WzljwpJV-py3.8\lib\site-packages\slackbot_helper\core\svc\analyze_slack_event.py", line 82, in _process
    user_ids = self._extract_user_ids(d_event)
  File "C:\Users\Craig\AppData\Local\pypoetry\Cache\virtualenvs\climate-bot-WzljwpJV-py3.8\lib\site-packages\slackbot_helper\core\dmo\user_id_extract.py", line 145, in process
    results = self._process(d_event)
  File "C:\Users\Craig\AppData\Local\pypoetry\Cache\virtualenvs\climate-bot-WzljwpJV-py3.8\lib\site-packages\slackbot_helper\core\dmo\user_id_extract.py", line 97, in _process
    [user_ids.append(x) for x in self._extract_ids(
TypeError: 'NoneType' object is not iterable
craigtrim commented 1 year ago

A related error

2022-11-16 10:57:05,464 : DEBUG : client.py : send_message() : 199 : Sending a message (session id: 65a3514c-b98e-4818-bedb-4c8ef3f36958, message: {"envelope_id": "f453b9a7-6e05-42f4-851f-a151d17b4f04"})
2022-11-16 10:57:05,466 : ERROR : user_id_extract.py : log_error() : 77 : Event Structure Parse Error for Blocks
        Start Event Block ---------------------------
        {'blocks': [{'block_id': 'af1',
             'text': {'text': '<@U046G4FURQT> *The capacity is low because* '
                              'water must be pumped up a hill, requiring a '
                              'large reservoir of water and, of course, a '
                              'hill.',
                      'type': 'mrkdwn',
                      'verbatim': False},
             'type': 'section'},
            {'block_id': 'b0W/O', 'type': 'divider'},
            {'block_id': 'Hph',
             'text': {'text': ':ledger: *avoid-climate-disaster* Chapter 4:',
                      'type': 'mrkdwn',
                      'verbatim': False},
             'type': 'section'},
            {'block_id': 'RyE',
             'elements': [{'action_id': '61+q',
                           'text': {'emoji': True,
                                    'text': 'Results Page Only',
                                    'type': 'plain_text'},
                           'type': 'button',
                           'url': 'https://iceberg-data-slack.s3.us-west-1.amazonaws.com/book/avoid-climate-disaster/page/CH04-PG29.jpg'},
                          {'action_id': 'Z470',
                           'text': {'emoji': True,
                                    'text': 'Entire Chapter',
                                    'type': 'plain_text'},
                           'type': 'button',
                           'url': 'https://iceberg-data-slack.s3.us-west-1.amazonaws.com/book/avoid-climate-disaster/chapter/CH04.pdf'}],
             'type': 'actions'}],
 'channel': 'C04BRFKKSNL',
 'team': 'T045AR44M70',
 'text': "This content can't be displayed.",
 'ts': 1668625025.508569,
 'type': 'app_mention',
 'user': 'U045HCSMG8K'}
        ----------------------------- End Event Block
2022-11-16 10:57:05,466 : DEBUG : internals.py : send_response() : 41 : Response time: 2 milliseconds
2022-11-16 10:57:05,466 : ERROR : listener_error_handler.py : handle() : 67 : Failed to run listener function (error: )
Traceback (most recent call last):
  File "C:\Users\Craig\AppData\Local\pypoetry\Cache\virtualenvs\climate-bot-WzljwpJV-py3.8\lib\site-packages\slackbot_helper\core\dmo\user_id_extract.py", line 92, in _process
    for inner in element['elements']:
KeyError: 'elements'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Craig\AppData\Local\pypoetry\Cache\virtualenvs\climate-bot-WzljwpJV-py3.8\lib\site-packages\slack_bolt\listener\thread_runner.py", line 120, in run_ack_function_asynchronously
    listener.run_ack_function(request=request, response=response)
  File "C:\Users\Craig\AppData\Local\pypoetry\Cache\virtualenvs\climate-bot-WzljwpJV-py3.8\lib\site-packages\slack_bolt\listener\custom_listener.py", line 50, in run_ack_function
    return self.ack_function(
  File ".\climate_bot\router.py", line 45, in app_mention
    d_event = app_mention_handler(body['event'])
  File "C:\Users\Craig\git\climate\climate-bot\climate_bot\app_mention\bp\app_mention_orchestrator.py", line 148, in handle
    d_event_normalized = normalize_event(
  File "C:\Users\Craig\AppData\Local\pypoetry\Cache\virtualenvs\climate-bot-WzljwpJV-py3.8\lib\site-packages\slackbot_helper\__init__.py", line 73, in normalize_event
    return NormalizeIncomingEvent(bot_ids).process(d_event)
  File "C:\Users\Craig\AppData\Local\pypoetry\Cache\virtualenvs\climate-bot-WzljwpJV-py3.8\lib\site-packages\slackbot_helper\core\bp\normalize_incoming_event.py", line 45, in process
    d_analyzed = self._analyze(d_transformed)
  File "C:\Users\Craig\AppData\Local\pypoetry\Cache\virtualenvs\climate-bot-WzljwpJV-py3.8\lib\site-packages\slackbot_helper\core\svc\analyze_slack_event.py", line 120, in process
    d_analyzed = self._process(d_event)
  File "C:\Users\Craig\AppData\Local\pypoetry\Cache\virtualenvs\climate-bot-WzljwpJV-py3.8\lib\site-packages\slackbot_helper\core\svc\analyze_slack_event.py", line 82, in _process
    user_ids = self._extract_user_ids(d_event)
  File "C:\Users\Craig\AppData\Local\pypoetry\Cache\virtualenvs\climate-bot-WzljwpJV-py3.8\lib\site-packages\slackbot_helper\core\dmo\user_id_extract.py", line 152, in process
    results = self._process(d_event)
  File "C:\Users\Craig\AppData\Local\pypoetry\Cache\virtualenvs\climate-bot-WzljwpJV-py3.8\lib\site-packages\slackbot_helper\core\dmo\user_id_extract.py", line 118, in _process
    raise ValueError
ValueError

It appears the more elaborate block formats throw this algorithm off