Repository navigation
Conversation
A Slack OAuth install now leaves the workspace installation attached to the owner recorded for that workspace. The callback rebuilds that owner's stored installation and writes it back; when the workspace has no recorded owner the installation is removed, and a token with no installation is revoked. Workspace identity links are left as they are, and the redirect still reports workspace_already_connected.
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Executive SummaryThe only change since the previous review is a new database-backed suite, Assumptions: Files Reviewed (3 files)
Previous Review Summaries (2 snapshots, latest commit 03c7470)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 03c7470)Status: No Issues Found | Recommendation: Merge Executive SummaryThe incremental change moves Slack conflict-rollback token revocation into a Assumptions: Files Reviewed (2 files)
Previous review (commit ae22586)Status: 3 Issues Found | Recommendation: Address before merge Executive SummaryThe conflict rollback restores the recorded owner's Chat SDK installation, but its cleanup paths can skip the token revocation when installation removal fails, and the restore path may write a token Slack has already invalidated. Assumptions: Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (2 files)
Reviewed by deepseek-flash-latest · Input: 86.2K · Output: 12.6K · Cached: 990.5K Review guidance: REVIEW.md from base branch |
Revoking a token that ends up with no installation now runs whether or not the installation write succeeds, and a revocation that does not complete is reported to Sentry. Adds coverage for a recorded integration without a token and for a removal that fails.
|
bot: Summary notes on head 03c7470:
|
|
bot: Closing as superseded by #8234. That PR checks workspace ownership under a lock before writing the Slack installation, and restores the saved installation on conflict. |
Evidence
Evidence: demonstrated — a database-backed suite,
apps/web/src/lib/integrations/oauth/platforms/slack-callback.db.test.ts, runs the callback handler against local Postgres with the Chat SDK adapter stubbed. It shows that a completed install redirects with the expected result, that the integration row recorded for the workspace keeps its values and ownership, that the Chat SDK installation is set from that row, that an exchange token that is not part of the recorded installation is revoked, and that no extra row is created. A second case shows a repeat install by the recorded owner updates its own row and leaves the installation untouched. A route-level suite covers the other branches.Summary
A Slack OAuth install now settles a workspace's Chat SDK installation from the integration recorded for that workspace.
The callback resolves the integration recorded for the workspace and makes the Chat SDK installation match it:
slackAdapter.setInstallation, so the workspace always resolves to the owner it is recordedfor.
slackAdapter.deleteInstallation.revocation that does not complete is captured to Sentry.
The redirect for a workspace the store reports as already connected still reports
error=workspace_already_connected, and a settle that fails falls back to removing theinstallation before that redirect.
The logic lives in
restoreRecordedSlackInstallationinapps/web/src/lib/integrations/oauth/platforms/slack-callback.ts, inside the conflict branch ofthe callback. It composes with the organization-authority path that
upsertSlackInstallationalready gates, and the callback still passes
allowWorkspaceRebindonly for organizationowners.
Verification
apps/web:NODE_ENV=test pnpm exec jest --runInBand src/lib/integrations/oauth/platforms/slack-callback.db.test.ts→ 2 passed against a migrated local Postgres.
apps/web:NODE_ENV=test pnpm exec jest --runInBand src/lib/integrations/oauth/platforms/slack-callback.test.ts→ 12 passed. Covers the redirect and each settle branch (recorded integration, no recorded
integration, recorded row without a token, write failure, removal failure, token reuse), plus
the organization authority cases on
main.apps/web:NODE_ENV=test pnpm exec jest --runInBand src/lib/integrations/slack-service.test.ts→ 26 passed.
apps/web:oxlint0 warnings, 0 errors on the changed files;oxfmtno differences;tsgo --noEmit --checkers 1clean.install cannot be completed from this environment, so the database-backed callback suite is
the end-to-end evidence. No screenshots apply.
Visual Changes
N/A
Production prerequisites
None.
Reviewer Notes
getInstallationByTeamIdis already exported byslack-service; no service changes.botToken,botUserId, andteamName. The adapter neverreads
enterpriseId/isEnterpriseInstallback from stored state, and the storage key is thesame
teamId, so the rebuild is equivalent for token resolution.on an existing install never revokes the live token.
metadata.access_token; if a row has none, theinstallation is removed instead of restored.
main; the two test files that both addedslack-callback.test.tsare combined into one suite.Proxy answers
The owner's proxy gave these answers in the owner's place.
Answer: Restore the existing owner's installation
Confidence: 0.60 · Precedent: Speed and least work: 'do the least amount of work possible, with no drop in quality'.
Answer: Revoke only when it differs from the binding
Confidence: 0.75 · Precedent: none
Answer: Fall back to delete, then redirect
Confidence: 0.55 · Precedent: Make on-call alerts informative and actionable.