Repository navigation
fix(slack): Link identities on install with the installer's user token - #132061
Open
sentry-junior[bot] wants to merge 1 commit into
Open
sentry-junior[bot] wants to merge 1 commit into
sentry-junior[bot] wants to merge 1 commit into
Conversation
The post-install task that links Slack members to Sentry users by email called users.list with the bot token. The bot token has no users:read.email scope, so Slack returned members without emails and the task matched no one beyond the installer. Pass the installer's user token, which has users:read.email, to the task instead. It is Fernet-encrypted with a one-hour TTL so it stays out of task arguments and error reports, and it is never stored on the integration. Without an encryption key (self-hosted) or once the token expires, the task falls back to the bot token as before. Co-Authored-By: Athena Moghaddam <132939361+sentaur-athena@users.noreply.github.com>
sentaur-athena
marked this pull request as ready for review
November 20, 2026 21:34
This branch has not been deployed
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.
Human description: We attempt to fetch users for org at the time of slack app installation but that piece doesn't work today because we drop the user token doing the installation. This PR fixes that issue
After a Slack install,
link_slack_user_identitiesmatches Slack members to Sentry org members by email and creates theirIdentitylinks. It calledusers.listwith the bot token. The bot scopes (identity_oauth_scopes) have never includedusers:read.email, which is only inuser_scopes. Slack leavesprofile.emailout ofusers.listfor tokens without that scope, soformat_slack_info_by_emaildropped every member and the task linked nobody. The installer is the exception, because the install pipeline links them directly. The existing tests mockedusers.listresponses with emails included, which is why they never caught this.The installer's user token does have
users:read.email, and Slack returns it inauthed_user.access_tokenduring OAuth. This PR uses that token for the lookup:build_integrationpasses the user token topost_installinpost_install_data. It is never written to the integration metadata.post_installencrypts the token withFernetKeyStorebefore queueing the task, so the plaintext token never appears in task arguments or error reports. This is the same approachsync_forge_installationuses for the Jira system token.users.listwith it.SlackSdkClientgets an optionalaccess_tokenoverride for this.The new task arguments are optional, so tasks queued before the deploy still run.
Adding
users:read.emailto the bot scopes is being handled separately. Workspaces only get a new bot scope when they reinstall, so this fix is what covers new installs on older app configurations.via @sentaur-athena.
--
View Session [Sentry]