[Teams] Fix team creation crash on free-text/Slack members#233
Merged
Conversation
queue_team's member loop used `if "id" in member`, a substring test
against the mixed string/object teamMembers array (freeSolo picker):
free-text names containing "id" matched then raised TypeError, others
were silently dropped. Guard with isinstance(member, dict) + .get("id").
Also replaces the undefined SLACK_USER_ID_PREFIX with
normalize_slack_user_id() (NameError that broke the whole flow).
Co-Authored-By: Claude Opus 4.7 <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.
Summary
Fixes the team-creation flow crashing with "An unexpected error occurred" after a user adds team members.
NameError: SLACK_USER_ID_PREFIX is not defined— the constant never existed. Replaced withnormalize_slack_user_id()(common/utils/oauth_providers.py), which builds the fulloauth2|slack|{workspace}-{id}form and passes already-prefixed ids through safely.teamMembersis afreeSoloautocomplete array carrying BOTH Slack-user objects ({id, name, real_name}) AND raw free-text name strings. The oldif "id" in memberran a substring test against strings: names containing "id" (Sidney/David/Madison) matched, thenmember["id"]raisedTypeError; other free-text was silently dropped. Now guarded withisinstance(member, dict)+member.get(...). Only objects with a Slack id are invited to the channel / linked tousers_list; free-text names are informational-only by design.Pairs with frontend PR opportunity-hack/frontend-ohack.dev#308.
Test plan
python -m py_compile api/teams/teams_service.pypasses.🤖 Generated with Claude Code