Skip to content

fix(org): match user and account emails case-insensitively - #9051

Open
vbhanuchander-lang wants to merge 1 commit into
apache:mainfrom
vbhanuchander-lang:org-email-case-insensitive
Open

fix(org): match user and account emails case-insensitively#9051
vbhanuchander-lang wants to merge 1 commit into
apache:mainfrom
vbhanuchander-lang:org-email-case-insensitive

Conversation

@vbhanuchander-lang

Copy link
Copy Markdown
Contributor

Summary

user_account.go keyed the map on the raw address and looked it up with the raw account address:

emails[user.Email] = user.Id                                              // line 49
...
if userId, ok := emails[account.Email]; account.Email != "" && ok {       // line 79

The two sides come from different systems — a git config, a provider profile, and a
hand-maintained CSV — which routinely disagree on the case of the same address. When they do, the
subtask still reports success, so the failure is invisible: the account just never appears in
user_accounts, and everything attributing through it stops counting towards that user.

There is no second chance either. The scan is restricted to
id NOT IN (SELECT account_id FROM user_accounts) (line 58), so a later run will not revisit an
account that failed to match.

What this changes

Case is folded on both sides of the email comparison only.

Name matching is deliberately untouched. Emails are case-insensitive by convention; personal
names and logins are not, and loosening those comparisons could manufacture links that are simply
wrong. That felt like a separate decision rather than something to slip into this fix.

Test Plan

The org e2e fixtures gain one account, a11, whose email (E6) differs from user U006's (e6)
only in case, with full_name and user_name set to zz so neither name fallback can match. That
isolates the email path.

Verified against a MySQL 8 instance with E2E_DB_URL set:

Result
Without the change FAILrecords in user_accounts count not match expectation count,[expected(CSV):11][actual(DB):10]
With the change ok github.com/apache/incubator-devlake/plugins/org/e2e

go test ./plugins/org/... -count=1 → e2e and impl both pass. go vet ./plugins/org/... is clean,
and go build ./plugins/org/tasks/ is clean.

Two pre-existing build complaints are unrelated to this change and reproduce identically on an
unmodified tree, which I checked rather than assumed: plugins/org reports
function main is undeclared in the main package because it builds as a Go plugin, and
git2go/v33 needs pkg-config, which is absent from my machine.

Context

Found while investigating #8698, where a reporter's GitHub account was never linked so only commit
activities showed in work logs. To be clear, case sensitivity is not the cause of that issue — I
posted the root cause there separately (GitHub returns an empty email for users who have not made it
public, and users.csv has no column for a provider login, so no branch can match). This is a
different instance of the same silent-linkage class that surfaced while reading the code.

🤖 AI-assisted changes — generated with Claude Code (Opus 5) and reviewed by me before submitting.

ConnectUserAccountsExact keyed its lookup map on the raw email address, so
the comparison was case-sensitive. A user imported from users.csv as
Tyrone.Cummings@corp.com was not linked to an account recorded as
tyrone.cummings@corp.com, and the account was left unlinked with no
warning: the subtask still reported success.

That matters because the two sides come from different systems. A git
config, a provider profile and a hand-maintained CSV routinely disagree on
the capitalisation of the same address, and email addresses are treated
case-insensitively everywhere else. Once an account is unlinked, everything
attributing through it stops counting towards that user, and the scan is
restricted to accounts not already in user_accounts, so a later run does
not revisit it.

Folds case on both sides of the email comparison. Name matching is left
exactly as it was, since names are not case-insensitive in the same way and
loosening them could create links that are simply wrong.

The org e2e fixtures gain account a11, whose email differs from user U006's
only in case, with a name and login that deliberately match nothing. It
fails before this change (10 rows against 11 expected) and passes after.
@vbhanuchander-lang
vbhanuchander-lang force-pushed the org-email-case-insensitive branch from 4ff35a9 to 0fe9af7 Compare August 13, 2026 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug][org] User/account linking compares emails case-sensitively and silently drops matches

1 participant