Automattic / jetpack

Security, performance, marketing, and design tools — Jetpack is made by WordPress experts to make WP sites safer and faster, and help you grow your traffic.
https://jetpack.com/
Other
1.58k stars 797 forks source link

Missing scopes not logged for automattic/action-test-results-to-slack@v0.3.1 #39341

Closed testlabauto closed 1 week ago

testlabauto commented 1 week ago

Impacted plugin

None / Other

Quick summary

Missing scopes not logged on failure with automattic/action-test-results-to-slack@v0.3.1

Steps to reproduce

  1. Use automattic/action-test-results-to-slack@v0.3.1 with channels:read and chat:write oauth enabled slack app
  2. Get error: Error: An API error occurred: missing_scope

Cannot determine which scope is missing from this error. Can you tell me what scopes are required?

A clear and concise description of what you expected to happen.

Post should appear in slack

What actually happened

Error Error: An API error occurred: missing_scope

Impact

One

Available workarounds?

No and the platform is unusable

If the above answer is "Yes...", outline the workaround.

No response

Platform (Simple and/or Atomic)

No response

Logs or notes

No response

jeherve commented 1 week ago

Could you try giving it the chat:write, chat:write.customize, and chat:write.public permissions, and let us know if that works for you?

testlabauto commented 1 week ago

Thank you for your prompt reply! I have adjusted my scopes to look like:

image

But I am still seeing:

No rules configuration found, returning only the default channel
  Found 1 channels
  No Playwright report path defined.
  No Playwright report found.
  Looking for push-6f4d2f856cfbaeecd42363402d151cbafdbda6d8

  /home/runner/work/_actions/automattic/action-test-results-to-slack/node_modules/.pnpm/@slack+web-api@7.3.2/node_modules/@slack/web-api/dist/errors.js:65
      const error = errorWithCode(new Error(`An API error occurred: ${result.error}`), ErrorCode.PlatformError);
  ^
  Error: An API error occurred: missing_scope
      at platformErrorFromResult (/home/runner/work/_actions/automattic/action-test-results-to-slack/node_modules/.pnpm/@slack+web-api@7.3.2/node_modules/@slack/web-api/dist/errors.js:65:1)
      at WebClient.<anonymous> (/home/runner/work/_actions/automattic/action-test-results-to-slack/node_modules/.pnpm/@slack+web-api@7.3.2/node_modules/@slack/web-api/dist/WebClient.js:[19](https://github.com/posit-dev/positron/actions/runs/10812811425/job/29995881345#step:3:20)8:1)
      at Generator.next (<anonymous>)
      at fulfilled (/home/runner/work/_actions/automattic/action-test-results-to-slack/node_modules/.pnpm/@slack+web-api@7.3.2/node_modules/@slack/web-api/dist/WebClient.js:28:1)
      at processTicksAndRejections (node:internal/process/task_queues:95:5)
testlabauto commented 1 week ago

Additional note: this very simple action is working: https://github.com/ivanklee86/xunit-slack-reporter (It only needs chat:write) Your action looks much better, though, so was definitely hoping to get it working.

anomiex commented 1 week ago

Looks like that error is coming from Slack's @slack/web-api package. There's nothing in the backtrace to indicate what call it was trying to do. You might try re-running it with debugging enabled to see if that outputs more information.

Based on the prior output and your screenshot, you might try also adding the channels:history scope. The "Looking for push-6f4d2f856cfbaeecd42363402d151cbafdbda6d8" message is output just before a call to conversations.history which requires that scope.

(We should probably document in the action's readme which scopes it needs...)

testlabauto commented 1 week ago

Thank you. That last addition of channels:history got it working! It's really awesome.

If you do update the docs, I would suggest also indicating that theslack-notification job in the example needs if: always().

anomiex commented 1 week ago

Good idea, although since https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/evaluate-expressions-in-workflows-and-actions#always suggests !cancelled() I went with that instead of always().

anomiex commented 1 week ago

To summarize: We can't really change what @slack/web-api logs. But we did figure out which scopes are needed, and we have a PR up to document that in the readme. So I'm going to declare this task "completed".