Skip to content

Commit 84075b1

Browse files
Merge pull request #111 from github/jasonmacgowan/422
Ignore adding team members that are not in the organization.
2 parents 2276dca + a16e5b0 commit 84075b1

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/entitlements/backend/github_team/service.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,11 @@ def add_user_to_team(user:, team:, role: "member")
459459
begin
460460
result = octokit.add_team_membership(team.team_id, user, role:)
461461
result[:state] == "active" || result[:state] == "pending"
462+
rescue Octokit::UnprocessableEntity => e
463+
raise e unless ignore_not_found && e.message =~ /Enterprise Managed Users must be part of the organization to be assigned to the team/
464+
465+
Entitlements.logger.warn "User #{user} not found in organization #{org}, ignoring."
466+
false
462467
rescue Octokit::NotFound => e
463468
raise e unless ignore_not_found
464469

0 commit comments

Comments
 (0)