This is an automated email from the ASF dual-hosted git repository.

klesh pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/devlake.git


The following commit(s) were added to refs/heads/main by this push:
     new c5a4fb6dc fix(org): match account names and logins case-insensitively 
(#9064)
c5a4fb6dc is described below

commit c5a4fb6dc8bd414a7b11424d8b6225d5d07d5d9e
Author: vbhanuchander-lang <[email protected]>
AuthorDate: Thu Aug 20 22:19:32 2026 -0400

    fix(org): match account names and logins case-insensitively (#9064)
    
    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 +
 backend/plugins/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 9b1f09eb8..fced94010 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 1e66cceb9..08c28000f 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 30cd37b76..c8ea94dea 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,

Reply via email to