fix(slack): Clear usergroup when no accepted students have Slack IDs - #62
Merged
tylermenezes merged 1 commit intoSep 18, 2026
Conversation
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.
Detail bug report: View on Detail
Bug
updateSlackUserGroupskeeps a Slack usergroup in sync with an event's currently-accepted students who have linked Slack IDs. When the roster became empty (e.g., all previously-added students left the program), aif (ids.length > 0)guard skipped the Slack API call entirely, so departed members stayed in the usergroup indefinitely.There was no way for the codebase to clear a usergroup: Slack's
usergroups.users.updaterejects an emptyuserslist (the guard only suppressed that error, it didn't clear the group), and nousergroups.disable/enableexisted anywhere in the repo. The stale group was then @-mentioned via<!subteam^...>on student-targeted scheduled announcements, addressing users who had left the program. Introduced in93061ab7, which wrapped the call in the guard and turned a previously-visibleno_users_providederror into a silent leak.Fix
slack.usergroups.disable(the only Slack API way to actually clear a group) and persistslackUserGroupId = nullon the event, both in the DB and in-memory.usergroups.createlazy — only when at least one accepted student has a Slack ID — so empty events don't create placeholder groups, and the cleared id lets the group be recreated fresh when students later re-join.sendScheduledAnnouncementsskip the stale<!subteam^...>mention (it already gated that token onslackUserGroupId).slackparameter (defaulting to the real client) so the logic is unit-testable offline; existing single-argument callers (slackSync.ts,slackArchive.ts) are unaffected.Testing
src/slack/updateSlackUserGroups.test.ts, following the repo's existing custom-harness convention) covering: empty-roster disable+clear, populated-roster update-only, lazy create+update, the no-op case (no group yet), accepted students without Slack IDs, multi-project flattening with null/emptyslackIdfiltering, and the re-join recreate path.prisma db push): seeded an active event with a populated usergroup, moved all students offACCEPTED, and confirmedusergroups.disablewas called andEvent.slackUserGroupIdpersisted asnullin the real database; restoring a student recreated a fresh group with a new id. Also ran the realsendScheduledAnnouncementstask against the database and confirmed a STUDENT-targeted Slack announcement posted the body with no<!subteam^...>mention when the id was cleared, and still appended the mention in the non-null contrast case.invalid_auth. I confirmed the fix'susergroups.disablecall is actually issued through the real@slack/web-apiWebClientvia the real hourlyslackSyncentry point (the call reaches Slack and fails only on authentication), but could not inspect the usergroup inside a real workspace to confirm Slack marks it disabled. That step requires an operator's Slack workspace token with theusergroups:writescope.@typescript-eslint/parseris incompatible with the repo's TypeScript 5.x across the whole tree (reproduces on untouched files), so it could not be run.Automatic Fixes PRs can be configured here.