danswer-ai / danswer

Gen-AI Chat for Teams - Think ChatGPT if it had access to your team's unique knowledge.
https://docs.danswer.dev/
Other
10.49k stars 1.28k forks source link

Slack bot integration user_not_found #1466

Open mforbak opened 5 months ago

mforbak commented 5 months ago

Hello,

I am trying to integrate Danswer with our Slack instance, and I have an app created, as mentioned in the docs, and I have created a channel and invited a bot into that.

After indexing ~16K documents I can now see the connector failed with Error MSG:

The request to the Slack API failed.
(url: https://www.slack.com/api/users.info)
The server responded with: {'ok': False, 'error': 'user_not_found'}

Any idea how to skip the problematic dokument? Run Update doesn't help, cause it trying to index the failed document again.

psblah commented 2 months ago

We have this issue as well, it seems to relate to a user who appears like this is our chat history now:

image

"Private user info" ?

They have been deleted, but other deleted users don't appear like this one so perhaps a particular process has occurred for this user that now has this unique state.

psblah commented 2 months ago

Stack trace here:

Traceback (most recent call last):
  File "/app/danswer/background/indexing/run_indexing.py", line 169, in _run_indexing
    for doc_batch in doc_batch_generator:
  File "/app/danswer/connectors/slack/connector.py", line 358, in poll_source
    for document in get_all_docs(
  File "/app/danswer/connectors/slack/connector.py", line 316, in get_all_docs
    yield thread_to_doc(
          ^^^^^^^^^^^^^^
  File "/app/danswer/connectors/slack/connector.py", line 155, in thread_to_doc
    initial_sender_expert_info = expert_info_from_slack_id(
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/danswer/connectors/slack/utils.py", line 119, in expert_info_from_slack_id
    response = make_slack_api_rate_limited(client.users_info)(user=user_id)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/danswer/connectors/slack/utils.py", line 80, in rate_limited_call
    response = call(**kwargs)
               ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/slack_sdk/web/client.py", line 4380, in users_info
    return self.api_call("users.info", http_verb="GET", params=kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/slack_sdk/web/base_client.py", line 156, in api_call
    return self._sync_send(api_url=api_url, req_args=req_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/slack_sdk/web/base_client.py", line 187, in _sync_send
    return self._urllib_api_call(
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/slack_sdk/web/base_client.py", line 317, in _urllib_api_call
    ).validate()
      ^^^^^^^^^^
  File "/usr/local/lib/python3.11/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://www.slack.com/api/users.info)
The server responded with: {'ok': False, 'error': 'user_not_found'}

perhaps we could modify this:

https://github.com/danswer-ai/danswer/blob/main/backend/danswer/connectors/slack/utils.py#L95

from

elif e.response["error"] in ["already_reacted", "no_reaction"]:

to

elif e.response["error"] in ["already_reacted", "no_reaction", "user_not_found"]:

so it ignores those errors returned by slack api?

mforbak commented 1 month ago

@psblah thank you! After changing the code it is working :)

image