Repository navigation
fix(slack): call auth.test when testing a connection - #9466
Open
ShivamSharma43 wants to merge 1 commit into
Open
ShivamSharma43 wants to merge 1 commit into
ShivamSharma43 wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
"Test Connection" for a Slack connection reports success for any token, including a revoked or mistyped one.
testConnectioninapi/connection.goonly calledapi.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 asslack.comis reachable. A bad token only shows up later, when the collectors fail withinvalid_auth(since #9440) during a pipeline run.Changes:
api/connection.go:testConnectionnow calls Slack'sauth.testmethod, which exists to check a token. Slack answers a bad token with HTTP 200 and{"ok": false, "error": "invalid_auth"}, so theokfield is checked and not only the status code. Onok: falsethe test fails withslack auth.test error: <error code>(400), the same message format as the collectors and the scope picker (listSlackRemoteScopes).linearplugin, so the browser does not show a Basic Auth dialog. Any other non-200 status fails with that status.testConnectionuses thectxit is given instead ofcontext.TODO().This follows the other plugins whose test calls a "who am I" endpoint (
linearwith aviewerquery,youtrackwithusers/me,teambitionwithorg/info).Does this close any open issues?
No issue is open for this. The bug is described above.
Screenshots
N/A
Other Information
api/connection_test.gorunstestConnectionagainst anhttptestserver standing in for the Slack API, followingyoutrack/api/connection_api_test.go. It checks thatok: truesucceeds and thatauth.testis called with theBearertoken, and thatok: false(with and without an error code), a 401 and a 500 fail. With the oldtestConnection, the success case fails because no request is made, and theok: falsecases fail because the test reports success.go test ./plugins/slack/...,go vet ./plugins/slack/...,gofmtandgolangci-lint run ./plugins/slack/...(v2.15.0) are clean (mocks generated with mockery v3.9.0 as inmake mock). Not run against a live Slack workspace.pr-type/bug-fix.Co-Authored-By:trailer.🤖 Generated with Claude Code