zaratanDotWorld / choreWheel

Computational governance tooling
GNU Affero General Public License v3.0
9 stars 0 forks source link

Investigate missing scope #173

Closed kronosapiens closed 1 week ago

kronosapiens commented 2 weeks ago

This error has appeared multiple times in the logs:

resolved choreClaim 1704
[ERROR]  bolt-app Error: An API error occurred: missing_scope
    at platformErrorFromResult (/home/ubuntu/mirror/node_modules/@slack/web-api/dist/errors.js:62:33)
    at WebClient.apiCall (/home/ubuntu/mirror/node_modules/@slack/web-api/dist/WebClient.js:181:56)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async exports.updateVoteResults (/home/ubuntu/mirror/src/bolt/common.js:242:16)
    at async /home/ubuntu/mirror/src/bolt/chores.app.js:103:7
    at async Array.<anonymous> (/home/ubuntu/mirror/node_modules/@slack/bolt/dist/middleware/builtin.js:245:9)
    at async Array.onlyEvents (/home/ubuntu/mirror/node_modules/@slack/bolt/dist/middleware/builtin.js:73:5)
    at async Promise.allSettled (index 1)
    at async /home/ubuntu/mirror/node_modules/@slack/bolt/dist/App.js:582:48
    at async Array.<anonymous> (/home/ubuntu/mirror/node_modules/@slack/bolt/dist/conversation-store.js:67:9) {
  code: 'slack_webapi_platform_error',
  data: {
    ok: false,
    error: 'missing_scope',
    needed: 'groups:history',
    provided: 'channels:history,channels:join,chat:write,commands,users:read',
    response_metadata: { scopes: [Array], acceptedScopes: [Array] }
  }
}
[ERROR]   An unhandled error occurred after ack() called in a listener

It is unclear the larger context, but it should be investigated and fixed.

More info here: https://api.slack.com/scopes/groups:history

kronosapiens commented 1 week ago

May be related:

/chores-channel 
[ERROR]  bolt-app Error: An API error occurred: method_not_supported_for_channel_type 
    at platformErrorFromResult (/home/ubuntu/mirror/node_modules/@slack/web-api/dist/errors.js:62:33) 
    at WebClient.apiCall (/home/ubuntu/mirror/node_modules/@slack/web-api/dist/WebClient.js:181:56) 
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) 
    at async exports.setChannel (/home/ubuntu/mirror/src/bolt/common.js:133:5) 
    at async /home/ubuntu/mirror/src/bolt/chores.app.js:151:3 
    at async Array.<anonymous> (/home/ubuntu/mirror/node_modules/@slack/bolt/dist/middleware/builtin.js:211:9) 
    at async Array.onlyCommands (/home/ubuntu/mirror/node_modules/@slack/bolt/dist/middleware/builtin.js:45:5) 
    at async Promise.allSettled (index 3) 
    at async /home/ubuntu/mirror/node_modules/@slack/bolt/dist/App.js:582:48 
    at async Array.<anonymous> (/home/ubuntu/mirror/node_modules/@slack/bolt/dist/conversation-store.js:67:9) { 
  code: 'slack_webapi_platform_error', 
  data: { 
    ok: false, 
    error: 'method_not_supported_for_channel_type',
    response_metadata: { scopes: [Array], acceptedScopes: [Array] }
   }
 }
 [ERROR]   An unhandled error occurred after ack() called in a listener
kronosapiens commented 1 week ago

After some digging, it seems like the issue is due to the app channel being set to a private channel. Posting to a private channel requires the additional groups:history scope, which is added in https://github.com/zaratanDotWorld/choreWheel/commit/54e4cbcbc58e15992ad413184eed6ba0f49d9ed3

The second bug is likely due to apps not being able to add themselves to private channels. If workspaces want to install apps to private channels, they will have to manually add the app to the channel. The docs are updated to reflect this in https://github.com/zaratanDotWorld/choreWheel/commit/6878afcd78fe8d2dc9e8b82560075c2e2100dbd1