Skip to content

not_authed error when interacting with an AI assistant #1198

@simonwhitaker

Description

@simonwhitaker

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

Reproducible in:

The slack_bolt version

slack_bolt==1.21.1
slack_sdk==3.33.1

Python runtime version

3.12.2

OS info

ProductName: macOS
ProductVersion: 15.1
BuildVersion: 24B83
Darwin Kernel Version 24.1.0: Thu Oct 10 21:00:32 PDT 2024; root:xnu-11215.41.3~2/RELEASE_ARM64_T6030

Steps to reproduce:

(Share the commands to run, source code, and project settings (e.g., setup.py))

  1. Follow the instructions here to add AI Assistant functionality to a Slack Bolt app
  2. Interact with the assistant by typing a message in the assistant split view

Expected result:

No error

Actual result:

not_authed error:

ERROR 2024-11-04 10:38:54,801 /Users/simon/.pyenv/versions/titaness/lib/python3.12/site-packages/django/utils/log.py - line 248: Internal Server Error: /slack/events {'taskName': None, 'status_code': 500, 'request': <ASGIRequest: POST '/slack/events'>}
Traceback (most recent call last):
  File "/Users/simon/.pyenv/versions/titaness/lib/python3.12/site-packages/asgiref/sync.py", line 518, in thread_handler
    raise exc_info[1]
  File "/Users/simon/.pyenv/versions/titaness/lib/python3.12/site-packages/django/core/handlers/exception.py", line 42, in inner
    response = await get_response(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/simon/.pyenv/versions/titaness/lib/python3.12/site-packages/asgiref/sync.py", line 518, in thread_handler
    raise exc_info[1]
  File "/Users/simon/.pyenv/versions/titaness/lib/python3.12/site-packages/django/core/handlers/base.py", line 253, in _get_response_async
    response = await wrapped_callback(
               ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/simon/.pyenv/versions/titaness/lib/python3.12/site-packages/asgiref/sync.py", line 468, in __call__
    ret = await asyncio.shield(exec_coro)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/simon/.pyenv/versions/titaness/lib/python3.12/site-packages/asgiref/current_thread_executor.py", line 40, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/simon/.pyenv/versions/titaness/lib/python3.12/site-packages/asgiref/sync.py", line 522, in thread_handler
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/simon/.pyenv/versions/titaness/lib/python3.12/site-packages/django/views/decorators/csrf.py", line 65, in _view_wrapper
    return view_func(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/simon/src/phoebe/monorepo/src/titaness/slack/views.py", line 23, in slack_events_handler
    return handler.handle(request)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/simon/.pyenv/versions/titaness/lib/python3.12/site-packages/slack_bolt/adapter/django/handler.py", line 176, in handle
    bolt_resp = self.app.dispatch(to_bolt_request(req))
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/simon/.pyenv/versions/titaness/lib/python3.12/site-packages/slack_bolt/app/app.py", line 549, in dispatch
    self._init_context(req)
  File "/Users/simon/.pyenv/versions/titaness/lib/python3.12/site-packages/slack_bolt/app/app.py", line 1399, in _init_context
    req.context["say"] = assistant.say
                         ^^^^^^^^^^^^^
  File "/Users/simon/.pyenv/versions/titaness/lib/python3.12/site-packages/slack_bolt/context/assistant/assistant_utilities.py", line 72, in say
    "event_payload": self.get_thread_context(),
                     ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/simon/.pyenv/versions/titaness/lib/python3.12/site-packages/slack_bolt/context/get_thread_context/get_thread_context.py", line 46, in __call__
    self._thread_context = self.thread_context_store.find(channel_id=self.channel_id, thread_ts=self.thread_ts)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/simon/.pyenv/versions/titaness/lib/python3.12/site-packages/slack_bolt/context/assistant/thread_context_store/default_store.py", line 33, in find
    parent_message = self._retrieve_first_bot_reply(channel_id, thread_ts)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/simon/.pyenv/versions/titaness/lib/python3.12/site-packages/slack_bolt/context/assistant/thread_context_store/default_store.py", line 40, in _retrieve_first_bot_reply
    messages: List[dict] = self.client.conversations_replies(
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/simon/.pyenv/versions/titaness/lib/python3.12/site-packages/slack_sdk/web/client.py", line 3229, in conversations_replies
    return self.api_call("conversations.replies", http_verb="GET", params=kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/simon/.pyenv/versions/titaness/lib/python3.12/site-packages/slack_sdk/web/base_client.py", line 157, in api_call
    return self._sync_send(api_url=api_url, req_args=req_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/simon/.pyenv/versions/titaness/lib/python3.12/site-packages/slack_sdk/web/base_client.py", line 188, in _sync_send
    return self._urllib_api_call(
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/simon/.pyenv/versions/titaness/lib/python3.12/site-packages/slack_sdk/web/base_client.py", line 319, in _urllib_api_call
    ).validate()
      ^^^^^^^^^^
  File "/Users/simon/.pyenv/versions/titaness/lib/python3.12/site-packages/slack_sdk/web/slack_response.py", line 199, in validate
    raise e.SlackApiError(message=msg, response=self)
slack_sdk.errors.SlackApiError: The request to the Slack API failed. (url: https://slack.com/api/conversations.replies)
The server responded with: {'ok': False, 'error': 'not_authed'}

Requirements

Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions