From fb20f3fa32151ef1eb4d7f26300a68fb4e3b0f44 Mon Sep 17 00:00:00 2001 From: Mathew Wicks <5735406+thesuperzapper@users.noreply.github.com> Date: Mon, 15 Jul 2024 11:18:26 -0700 Subject: [PATCH] fix: always retrieve github emails when `preferredEmailDomain` is set (#3584) Signed-off-by: Mathew Wicks <5735406+thesuperzapper@users.noreply.github.com> --- connector/github/github.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/connector/github/github.go b/connector/github/github.go index a7818579e2..18a56628af 100644 --- a/connector/github/github.go +++ b/connector/github/github.go @@ -531,9 +531,10 @@ func (c *githubConnector) user(ctx context.Context, client *http.Client) (user, return u, err } - // Only public user emails are returned by 'GET /user'. u.Email will be empty - // if a users' email is private. We must retrieve private emails explicitly. - if u.Email == "" { + // Only public user emails are returned by 'GET /user'. + // If a user has no public email, we must retrieve private emails explicitly. + // If preferredEmailDomain is set, we always need to retrieve all emails. + if u.Email == "" || c.preferredEmailDomain != "" { var err error if u.Email, err = c.userEmail(ctx, client); err != nil { return u, err