Skip to content

fix(slack): call auth.test when testing a connection - #9466

Open
ShivamSharma43 wants to merge 1 commit into
apache:mainfrom
ShivamSharma43:fix/slack-test-connection-auth-test
Open

ShivamSharma43 wants to merge 1 commit into
apache:mainfrom
ShivamSharma43:fix/slack-test-connection-auth-test

Conversation

@ShivamSharma43

Copy link
Copy Markdown
Contributor

Summary

"Test Connection" for a Slack connection reports success for any token, including a revoked or mistyped one.

testConnection in api/connection.go only called api.NewApiClientFromConnection. Without a proxy, that checks that the endpoint host resolves and accepts a TCP connection, and nothing else. The token is never sent to Slack, so the check passes as long as slack.com is reachable. A bad token only shows up later, when the collectors fail with invalid_auth (since #9440) during a pipeline run.

Changes:

  • api/connection.go: testConnection now calls Slack's auth.test method, which exists to check a token. Slack answers a bad token with HTTP 200 and {"ok": false, "error": "invalid_auth"}, so the ok field is checked and not only the status code. On ok: false the test fails with slack auth.test error: <error code> (400), the same message format as the collectors and the scope picker (listSlackRemoteScopes).
  • A 401 or 403 is reported as 400, as in the linear plugin, so the browser does not show a Basic Auth dialog. Any other non-200 status fails with that status.
  • testConnection uses the ctx it is given instead of context.TODO().

This follows the other plugins whose test calls a "who am I" endpoint (linear with a viewer query, youtrack with users/me, teambition with org/info).

Does this close any open issues?

No issue is open for this. The bug is described above.

Screenshots

N/A

Other Information

  • New api/connection_test.go runs testConnection against an httptest server standing in for the Slack API, following youtrack/api/connection_api_test.go. It checks that ok: true succeeds and that auth.test is called with the Bearer token, and that ok: false (with and without an error code), a 401 and a 500 fail. With the old testConnection, the success case fails because no request is made, and the ok: false cases fail because the test reports success.
  • go test ./plugins/slack/..., go vet ./plugins/slack/..., gofmt and golangci-lint run ./plugins/slack/... (v2.15.0) are clean (mocks generated with mockery v3.9.0 as in make mock). Not run against a live Slack workspace.
  • Suggested label: pr-type/bug-fix.
  • This PR was prepared with AI assistance (Claude Code). The commit carries a Co-Authored-By: trailer.

🤖 Generated with Claude Code

testConnection only built an API client, which checks that the
endpoint host resolves and accepts TCP connections, and then reported
success. The token was never sent to Slack, so "Test Connection" passed
for any token, including a revoked or mistyped one, and the problem
only showed up later when a pipeline ran.

Call Slack's auth.test method, which exists to check a token. Slack
answers a bad token with HTTP 200 and {"ok": false, "error":
"invalid_auth"}, so the ok field is checked as well as the status code,
and the test fails with "slack auth.test error: <error code>". A 401 or
403 is reported as 400, as in the linear plugin, so the browser does not
show a Basic Auth dialog. The test now also uses the request context
instead of context.TODO().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 28, 2026 14:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants