Write GitHub username to Slack profile after org invite - #19
Merged
Conversation
When a core-team member uses the "Add to GitHub org" shortcut on a #github-invitations workflow message, the bot now back-fills the requester's GitHub handle into their Slack profile's GitHub field. - `set_github_username()` writes via an admin user token (xoxp-), since a bot token cannot edit another member's profile. Best-effort and skip-if-already-set, so it never clobbers a handle the member entered and never affects the invite outcome. - New optional `SLACK_ADMIN_USER_TOKEN` config; unset = silent no-op. - Wired into the shared `invite_and_greet` success path, guarded on a resolved Slack user ID, so it no-ops on paths where the handle already came from the profile. - Infra: add the token to `ssm_secret_names` so ECS injects it. - Docs: document the user-token setup, and fix the SSM parameter path in deployment.md (`/nf-core/` -> `/nf-core-bot/`) to match the stack. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
ewels
force-pushed
the
feature/github-profile-writeback
branch
from
June 22, 2026 17:54
da42d52 to
688cb1c
Compare
ewels
added a commit
that referenced
this pull request
Jun 22, 2026
* Fix profile write-back: target the API-managed "GitHub (auto)" field PR #19 wrote handles into the member-editable "GitHub" field, which Slack silently no-ops (users.profile.set only persists for fields whose Data source is "API"). Profile write-back therefore did nothing in production. - Write to a dedicated "GitHub (auto)" custom field (label contains "github" + "auto"), which has its Data source set to API. Reads/lookups stay on the member-editable "GitHub" field. - Store the value as a GitHub URL with `@handle` display text (the field is a link type — bare handles are silently rejected). - Populate the auto field for everyone (drop the old "skip if the member field is set" rule); only skip when the auto field is already populated (idempotent). - Resolve the two fields separately by label; the member resolver now excludes the "(auto)" field. - Document the two-field setup + the mandatory "Data source = API" step. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Apply ruff format to test_slack_profile.py Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <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.
What & why
When a core-team member uses the Add to GitHub org message shortcut on a
#github-invitationsworkflow request, the bot already parses the requester's GitHub handle to send the invite — but then discards it. This PR back-fills that handle into the requester's Slack profile GitHub field, so it's stored permanently (and available to the slash-command/shortcut flows that read it).How it works
set_github_username()inchecks/slack_profile.py. A bot token cannot edit another member's profile, so the write goes through an admin user token (xoxp-,users.profile:write). The custom field is set via theprofile=argument.invite_and_greet()success path, guarded on a resolved Slack user ID — so it naturally no-ops on the paths where the handle came from the profile in the first place.SLACK_ADMIN_USER_TOKENconfig — unset ⇒ silent no-op, so local dev and any unconfigured workspace are unaffected.Infra / ops
SLACK_ADMIN_USER_TOKENtossm_secret_namesinbot_stack.pyso ECS injects it./nf-core-bot/SLACK_ADMIN_USER_TOKENalready created, and the stack has been deployed (ECS task rolled over).deployment.md:/nf-core/→/nf-core-bot/to match what the stack actually reads.slack-app-setup.md.Tests
5 new tests in
test_slack_profile.py: writes-when-empty, skip-when-already-set, no-op-without-token, no-field-id, never-raises. Full suite: 546 passing; ruff + mypy clean.🤖 Generated with Claude Code