slack-ruby / slack-ruby-client

A Ruby and command-line client for the Slack Web, Real Time Messaging and Event APIs.
MIT License
1.21k stars 216 forks source link

missing_scope error instead of channel_not_found #492

Closed lukefoster11 closed 1 year ago

lukefoster11 commented 1 year ago

When trying to update or delete a message and using an incorrect channel ID, you get a missing_scope error rather than a channel_not_found error.

dblock commented 1 year ago

This seems to come from Slack rather than the library. Can you reproduce with curl, and maybe report it to Slack?

lukefoster11 commented 1 year ago

This seems to come from Slack rather than the library. Can you reproduce with curl, and maybe report it to Slack?

I'm not sure that's the case. With curl I get channel_not_found:

curl -d "text=Hi, this is edited." -d "channel=#luke-test" -d "ts=1691530316.768129" -H "Authorization: Bearer xoxb-token" -X POST https://slack.com/api/chat.update

{"ok":false,"error":"channel_not_found"}

But with the exact same call through slack-ruby-client I get missing_scope:

Slack.configure do |config|
  config.token = "xoxb-token"
end
client = Slack::Web::Client.new
client.chat_update(text: "Hi, this is edited.", channel: "#luke-test", ts: "1691530316.768129")

Slack::Web::Api::Errors::MissingScope: missing_scope
from /Users/lukefoster/.rbenv/versions/3.0.5/lib/ruby/gems/3.0.0/gems/slack-ruby-client-1.0.0/lib/slack/web/faraday/response/raise_error.rb:21:in `on_complete'
dblock commented 1 year ago

@lukefoster11 what's the full stack here and do you get the same error when using the channel ID instead of name?

Resolving names is a nice feature of slack-ruby-client. When you use #luke-test, it will call id_for which calls conversations_list, which I imagine raises this error. Now, is this expected that the bot token doesn't have the right scope to enumerate channels or are we passing wrong flags to conversations_list?

lukefoster11 commented 1 year ago

I see, the token doesn't have the right scope to enumerate channels, but I had no idea that's what it was trying to do under the surface. Using the channel ID works just fine. Sounds like this isn't an issue, just a feature that I wasn't aware of and working with.