slackapi / python-slack-sdk

Slack Developer Kit for Python
https://tools.slack.dev/python-slack-sdk/
MIT License
3.86k stars 835 forks source link

Slack `bot.info` returns `bot_not_found` for bot id `B01` #1260

Closed nzlosh closed 2 years ago

nzlosh commented 2 years ago

The errbot project uses the Python Slack SDK, users are reporting exceptions being raised when username resolution is applied to some bot messages.

Based on discussions here https://github.com/errbotio/err-backend-slackv3/pull/74#discussion_r961781175, B01 is being passed as a bot id, but will return not found when querying the slack API.

Is there any official documentation for this magic id and are there others that would need to be taken into account. I'm unable to find any official documentation regarding the bot id B01, with exception to the hubot slack SDK containing a mapping.

https://github.com/slackapi/hubot-slack/blob/c0c0d8d348b1522afa9835ef84a46f2bfbc6cdaf/src/client.coffee#L53

Why does the hubot code appear to have special handling of this id (and others) but the Python SDK does not? Are projects dependant on Python Slack SDK expected to implement their own error handling around this?

Reproducible in:

pip freeze | grep slack
python --version
sw_vers && uname -v # or `ver`

The Slack SDK version

slack-sdk==3.18.1
slackeventsapi==3.0.1

Python runtime version

Python 3.7.5

OS info

#203-Ubuntu SMP Wed Aug 10 17:40:03 UTC 2022

Steps to reproduce:

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

1. 2. 3.

Expected result:

Expect all bot id's sent from Slack's API to be resolvable via bot_info method.

Actual result:

API responds with bot found error when search bot id B01.

seratch commented 2 years ago

Hi @nzlosh, thanks for writing in!

Is there any official documentation for this magic id and are there others that would need to be taken into account. I'm unable to find any official documentation regarding the bot id B01, with exception to the hubot slack SDK containing a mapping.

We're sorry about the confusion here and your understanding of the magic numbers here are correct. Also, unfortunately, there is no detailed guide about these special IDs (Bot ID: B01, user ID: USLACKBOT).

Why does the hubot code appear to have special handling of this id (and others) but the Python SDK does not? Are projects dependant on Python Slack SDK expected to implement their own error handling around this?

Ideally, all the official SDKs should have some feature similar to hubot-slack but we are not planning to add such at least in the short term. So, as a workaround, please go ahead with the same approach with hubot-slack, meaning skipping bots.info API calls with B01.

I hope this was helpful to you and we'd be grateful if you could understand this.

nzlosh commented 2 years ago

Thank you for taking the time to confirm that, I'll apply a workaround as suggested.