From c251330405affa56c1e57d0f51c90b698cd9025e Mon Sep 17 00:00:00 2001 From: Bhanu Chander Vallabaneni Date: Wed, 19 Aug 2026 20:03:29 -0400 Subject: [PATCH] fix(org): match account names and logins case-insensitively Emails were made case-insensitive in #9051, but the display name and provider login comparisons in ConnectUserAccountsExact still matched exactly. Provider logins are themselves case-insensitive, and a corporate git config and a provider profile routinely record the same display name with different capitalisation, so an account whose login differs from the users.csv name only in case is silently left unlinked - and every activity that attributes through that account goes missing. Towards #8698, where a GitHub account with no public email can only link through these name paths. Extends the org e2e fixtures with an account whose login differs from the user's name only in case; without the change it is not linked and the expected row count drops from 12 to 11. --- backend/plugins/org/e2e/raw_tables/accounts.csv | 1 + .../org/e2e/snapshot_tables/user_accounts.csv | 1 + backend/plugins/org/tasks/user_account.go | 13 +++++++------ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/backend/plugins/org/e2e/raw_tables/accounts.csv b/backend/plugins/org/e2e/raw_tables/accounts.csv index 9b1f09eb84e..fced94010b6 100644 --- a/backend/plugins/org/e2e/raw_tables/accounts.csv +++ b/backend/plugins/org/e2e/raw_tables/accounts.csv @@ -2,6 +2,7 @@ "a1","2022-07-10 14:27:43.813","2022-07-10 14:27:43.813","","",0,"","e1","","n1","n1","","2022-07-10 14:27:43.813",0 "a10","2022-07-10 14:27:43.813","2022-07-10 14:27:43.813","","",0,"","e15","","pq","n10","","2022-07-10 14:27:43.813",0 "a11","2022-07-10 14:27:43.813","2022-07-10 14:27:43.813","","",0,"","E6","","zz","zz","","2022-07-10 14:27:43.813",0 +"a12","2022-07-10 14:27:43.813","2022-07-10 14:27:43.813","","",0,"","","","","N7","","2022-07-10 14:27:43.813",0 "a2","2022-07-10 14:27:43.813","2022-07-10 14:27:43.813","","",0,"","e1","","n2","n2","","2022-07-10 14:27:43.813",0 "a3","2022-07-10 14:27:43.813","2022-07-10 14:27:43.813","","",0,"","e2","","xyz","n3","","2022-07-10 14:27:43.813",0 "a4","2022-07-10 14:27:43.813","2022-07-10 14:27:43.813","","",0,"","e4","","n4","n4","","2022-07-10 14:27:43.813",0 diff --git a/backend/plugins/org/e2e/snapshot_tables/user_accounts.csv b/backend/plugins/org/e2e/snapshot_tables/user_accounts.csv index 1e66cceb992..08c28000f38 100644 --- a/backend/plugins/org/e2e/snapshot_tables/user_accounts.csv +++ b/backend/plugins/org/e2e/snapshot_tables/user_accounts.csv @@ -2,6 +2,7 @@ account_id,user_id,_raw_data_params,_raw_data_table,_raw_data_id,_raw_data_remar a1,U111,,,, a10,U010,,,0, a11,U006,,,0, +a12,U007,,,0, a2,U112,,,, a3,U113,,,, a4,U004,,,0, diff --git a/backend/plugins/org/tasks/user_account.go b/backend/plugins/org/tasks/user_account.go index 30cd37b76a7..c8ea94deae8 100644 --- a/backend/plugins/org/tasks/user_account.go +++ b/backend/plugins/org/tasks/user_account.go @@ -43,9 +43,10 @@ func ConnectUserAccountsExact(taskCtx plugin.SubTaskContext) errors.Error { if err != nil { return err } - // Email addresses are compared case-insensitively: a corporate git config and a provider - // profile routinely record the same address with different capitalisation, and matching them - // exactly silently drops links that should be made. + // Email addresses, display names and provider logins are all compared case-insensitively: a + // corporate git config and a provider profile routinely record the same address or name with + // different capitalisation, and provider logins are themselves case-insensitive, so matching + // them exactly silently drops links that should be made. emails := make(map[string]string) names := make(map[string]string) for _, user := range users { @@ -53,7 +54,7 @@ func ConnectUserAccountsExact(taskCtx plugin.SubTaskContext) errors.Error { emails[strings.ToLower(user.Email)] = user.Id } if user.Name != "" { - names[user.Name] = user.Id + names[strings.ToLower(user.Name)] = user.Id } } clauses := []dal.Clause{ @@ -88,7 +89,7 @@ func ConnectUserAccountsExact(taskCtx plugin.SubTaskContext) errors.Error { }, }, nil } - if userId, ok := names[account.FullName]; account.FullName != "" && ok { + if userId, ok := names[strings.ToLower(account.FullName)]; account.FullName != "" && ok { return []interface{}{ &crossdomain.UserAccount{ UserId: userId, @@ -96,7 +97,7 @@ func ConnectUserAccountsExact(taskCtx plugin.SubTaskContext) errors.Error { }, }, nil } - if userId, ok := names[account.UserName]; account.UserName != "" && ok { + if userId, ok := names[strings.ToLower(account.UserName)]; account.UserName != "" && ok { return []interface{}{ &crossdomain.UserAccount{ UserId: userId,