fix(org): match user and account emails case-insensitively - #9051
Open
vbhanuchander-lang wants to merge 1 commit into
Open
fix(org): match user and account emails case-insensitively#9051vbhanuchander-lang wants to merge 1 commit into
vbhanuchander-lang wants to merge 1 commit into
Conversation
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
force-pushed
the
org-email-case-insensitive
branch
from
August 13, 2026 11:58
4ff35a9 to
0fe9af7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ConnectUserAccountsExactcompared emails by exact map lookup, so addresses differing only incapitalisation were never linked and the account was silently left out of
user_accounts.user_account.gokeyed the map on the raw address and looked it up with the raw account address: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 anaccount 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
orge2e fixtures gain one account,a11, whose email (E6) differs from userU006's (e6)only in case, with
full_nameanduser_nameset tozzso neither name fallback can match. Thatisolates the email path.
Verified against a MySQL 8 instance with
E2E_DB_URLset:FAIL—records in user_accounts count not match expectation count,[expected(CSV):11][actual(DB):10]ok github.com/apache/incubator-devlake/plugins/org/e2ego 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/orgreportsfunction main is undeclared in the main packagebecause it builds as a Go plugin, andgit2go/v33needspkg-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.csvhas no column for a provider login, so no branch can match). This is adifferent 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.