Repository navigation
CXH-3517: discover Slack workspaces with the bot token - #103
c1-squire-dev[bot] wants to merge 7 commits into
Conversation
…full workspace discovery) Co-authored-by: c1-squire-dev[bot] <c1-squire-dev[bot]@users.noreply.github.com>
… in workspace tests (adversarial review FN1/FN2) Co-authored-by: c1-squire-dev[bot] <c1-squire-dev[bot]@users.noreply.github.com>
Co-authored-by: c1-squire-dev[bot] <c1-squire-dev[bot]@users.noreply.github.com>
Superseded — see the current review report for commit
|
Superseded — see the current review report for commit
|
There was a problem hiding this comment.
No blocking issues found — see the full review report
Strengthen the WrapError-classification assertion from a generic status.FromError check to status.Code(err) == codes.Unauthenticated, per judge suggestion. Co-authored-by: connector-farm <noreply@conductorone.com> Co-authored-by: c1-squire-dev[bot] <c1-squire-dev[bot]@users.noreply.github.com>
Superseded — see the current review report for commit
|
Superseded — see the current review report for commit
|
There was a problem hiding this comment.
No blocking issues found — see the full review report
…gth-limit Co-authored-by: c1-squire-dev[bot] <c1-squire-dev[bot]@users.noreply.github.com>
Superseded — see the current review report for commit
|
Superseded — see the current review report for commit
|
There was a problem hiding this comment.
No blocking issues found — see the full review report
… log convention Co-authored-by: c1-squire-dev[bot] <c1-squire-dev[bot]@users.noreply.github.com>
Superseded — see the current review report for commit
|
Superseded — see the current review report for commit
|
There was a problem hiding this comment.
No blocking issues found — see the full review report
Deep-review round 2 flagged the surviving useBotToken parameter as a silent wrong-token footgun: after deleting GetAuthTeamsList every caller passed true, leaving post's false branch dead code that selects the SCIM user token. post now authenticates with the bot token unconditionally; SCIM methods keep calling doRequest directly with the user token. Co-authored-by: c1-squire-dev[bot] <c1-squire-dev[bot]@users.noreply.github.com>
Superseded — see the current review report for commit
|
Connector PR Review: CXH-3517: discover Slack workspaces with the bot tokenBlocking Issues: 0 | Suggestions: 1 | Threads Resolved: 0 Review SummaryThe new commit (
There is no provisioning, config schema, Security IssuesNone found. Correctness IssuesNone found. Suggestions
Prompt for AI agentsReviewed commit: |
There was a problem hiding this comment.
No blocking issues found — see the full review report
CXH-3517: workspace discovery depends on which token class lands in
--token, and nothing guarded or documented thatWhat was asked
CXH-3517 reports that a customer with four Slack workspaces installed on the app synced only one: workspace discovery ran
auth.teams.listagainst a user OAuth token, which only returns workspaces the authorizing user is a member of. The same call with the Bot User OAuth Token returns every workspace where the app is installed. The ticket asks for discovery to use the bot token, or — if the user-token behavior stays — for the docs to say the authorizing user must be a member of every workspace they want synced.The code has moved on since the ticket's citation. The method it names (
GetAuthTeamsList) stopped being called when enterprise-specific discovery was removed in December 2025 (4e9c5ab5); today all discovery goes through the slack-go client built fromconfig.TokeninNewSlack. So with a bot token configured as documented, discovery already returns every installed workspace. What had not changed: nothing stopped a deployment from putting a user token in--token— the setup docs even make that easy — and when that happens the symptom is silent: fewer workspaces, no error, no log line. This PR makes that misconfiguration impossible to miss and removes the dead code that still carried the user-token default the ticket quoted.What changed
1.
pkg/connector/client/slack.goandpkg/connector/client/path.goWhere:
GetAuthTeamsListwas at slack.go L207-243;UrlPathAuthTeamsListwas path.go L13. Both deleted.What changed
GetAuthTeamsListmethod and the now-unusedUrlPathAuthTeamsListconstant.post'suseBotTokenswitch was removed entirely in review:postnow always authenticates with the bot token (the switch had become vestigial — every remaining caller passedtrue— and a lingeringfalsebranch would silently pick the SCIM user token for any future Web API call), while the SCIM methods keep callingdoRequestdirectly with the user token.Why
useBotToken=falsedefault is exactly what the ticket quotes. Keeping a boolean switch that can silently re-introduce the bug the ticket documents is worse than removing the switch. A grep over the repo confirms no references remain.2.
pkg/connector/connector.goWhere:
NewSlack~L112-113, right after the logger is set up.What changed
--tokenstarts withxoxp(a user OAuth token),NewSlacklogs one warning naming the symptom and the fix: discovery will only list the workspaces the authorizing user belongs to, and the Bot User OAuth Token is what discovers every installed workspace. Warn only — startup and sync behavior are unchanged, and unknown token shapes are not warned about.Why
3.
pkg/connector/workspace_test.go(new)Where: whole file;
TestWorkspaceList_MultiTeamDiscoveryL114,TestWorkspaceList_ErrorPropagationL157,newStubbedTeamsBuilderL93,memSessionStoreL24.What changed
workspaceResourceType.List) against a local stub server that answersauth.teams.list— and answers nothing else; a non-POST or wrong-path request gets a 500, so the test fails if discovery ever drifts off that endpoint.ok: falseand asserts the connector returns a typedUnauthenticatederror wrapped with the connector's own error message instead of an empty result.Listmakes; the vendored SDK's session helper panics on a nil store with non-empty results, so the stub is required.Why
4.
README.mdanddocs/connector.mdxWhere: README L23; connector.mdx L121-124 (outside the auto-generated capabilities block).
What changed
Why
How far this is verified
scripts/validate-changes.sh): exit 0, both new tests green alongside the existing package tests. Repo-wide builds were not run. CI ran and is green on the final head, includingverify / lint,verify / testandconnector-docs / validate.codes.Unauthenticatedexactly rather than "some gRPC status" (done), CI lint flagged a 233-character warn line (fixed by splitting the string literal, message unchanged), and the independent review below asked for two more changes, all applied.cmd/baton-slackbuilds and starts (SMOKE PASS, partial). This repo declares no mock for the smoke harness, so no sync was exercised by the smoke itself — the mock-based sync comparison above and the tester's own mock-backed sync (which discovered every stubbed workspace through 2-page pagination) are what exercised a real sync.baton-slack:log convention — fixed; the vestigialuseBotTokenswitch onpostwas itself the wrong-token trap this PR removes elsewhere — removed entirely, sopostnow always authenticates with the bot token). All three threads were answered and resolved; the judge re-passed the PR after each fix.What to look at hardest
xoxpprefix. A user-token shape Slack introduces without that prefix would stay silent (docs are the fallback). The check is deliberately narrow to avoid false warnings on GovSlack or future shapes.pkg/connector/clientpackage. Zero in-repo callers since4e9c5ab5; anything importing that package from outside this repo (none is known) would need to adjust.Linear requirements
CXH-3517 — this PR meets the ticket's acceptance criteria via its documented alternative, with the primary ask satisfied at the architectural level:
--tokenis configured as documented (connector.goL122); the new tests pin that path (workspace_test.goL114). The ticket's premise predated the December 2025 refactor (4e9c5ab5) that moved discovery off the user token.GetAuthTeamsListno longer defaults to the user tokenuseBotToken=trueswitch on that method; the method has had no callers since that refactor, so removal is the honest form of the same change.xoxpwarning at init (connector.goL112-113).Release Notes
baton-slack now warns at startup when the access token is a user OAuth token instead of the Bot User OAuth Token, because workspace discovery only lists the workspaces the authorizing user is a member of when a user token is used — pass the Bot User OAuth Token as
--tokento sync every workspace where the Slack app is installed. The README and connector setup docs now state which token belongs in which field, and a long-dead code path that still carried the old user-token discovery default was removed. Synced data, resource IDs and connector behavior are unchanged.Scope
Exactly six files:
pkg/connector/client/slack.go,pkg/connector/client/path.go,pkg/connector/connector.go,pkg/connector/workspace_test.go(new),README.md,docs/connector.mdx. No config schema, vendor, resource-type, entitlement or provisioning changes.