Skip to content

fix(github): ignore organizations when looking up co-author emails - #5325

Merged
lukaszgryglicki merged 1 commit into
linuxfoundation:devfrom
SoulPancake:fix/co-author-org-match
Nov 24, 2026
Merged

lukaszgryglicki merged 1 commit into
linuxfoundation:devfrom
SoulPancake:fix/co-author-org-match

Conversation

@SoulPancake

Copy link
Copy Markdown
Contributor

Fixes #5324

SearchGithubUserByEmail uses the first result of a GitHub user search for a co-author email. Organizations are included in that search, so an email that is also an organization's public email can match the organization.

  • Add type:user to the search query.
  • If an organization is still returned, ignore it so the lookup falls back to the database lookup.
  • Add tests for both.

Tested the changed function and the new tests in isolation against go-github v37, since the package depends on private modules.

Signed-off-by: SoulPancake <angbpy@gmail.com>
@SoulPancake
SoulPancake requested a review from a team as a code owner November 19, 2026 14:46
Copilot AI balanced review requested due to automatic review settings November 19, 2026 14:46
@lfx-one

lfx-one commented Nov 19, 2026 •

Copy link
Copy Markdown

@SoulPancake I'm starting review 1 of this pull request now (started 2026-11-19 14:46 UTC using review agent v0.1.34). This usually takes a few minutes. I'll update this comment with the summary when I'm done. If there's no summary here after about 45 minutes, the review stopped: push a new commit, or post a comment that begins with a mention of me followed by re-review, to start another. For help with the review agent, see https://github.com/linuxfoundation/lfx-review-agent/issues.


Hi @SoulPancake, thanks for the contribution.

Summary

This pull request makes the co-author email lookup skip GitHub organizations. It adds type:user to the search query and ignores an organization result that still comes back. The change is small and focused, and both new tests cover it.

Decision

⚠️ Review passed, human approval required

This pull request passed automated review, but its author isn't a verified member of the linuxfoundation GitHub organization, so I can't approve it. A maintainer needs to review and approve it before merge.

Details

Overall impression: SearchGithubUserByEmail in cla-backend-go/github/github_repository.go now sends <email> in:email type:user. If the first result still has type Organization, the function returns nil, nil. The caller GetCoAuthorCommits then moves on to the database lookup by email, as the PR describes. I followed that caller path and found no side effects: a nil user from this step leaves the later lookups unchanged, which matches how a "no result" case already behaved. The tests check the exact query string and the organization fallback. I found no correctness, security, performance, privacy or documentation issues. CO_AUTHORS.md describes the email lookup only in general terms, and this change keeps that description accurate.

Other reviewers and CI checks: The required check DCO passed on 3cc28a9. CodeRabbit's status was still pending when I read it. I did not wait for it, and its findings, if any, are not reflected here.

Rule files: read CLAUDE.md; skipped none

Questions, problems, or feedback: https://github.com/linuxfoundation/lfx-review-agent/issues

@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The GitHub email search now filters for users and returns no user when its first result is an organization. Tests cover the query and both result types.

Changes

GitHub Email Search

Layer / File(s) Summary
Filter and validate search results
cla-backend-go/github/github_repository.go, cla-backend-go/github/github_repository_test.go
The search query includes type:user. The function ignores organization results and returns other results. Tests verify the query and user and organization handling.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: Minimal · up to 3cc28

Co-author email lookups now skip organizations and fall back to the existing lookup path, matching the linked issue. No concrete merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the fix (ignoring organizations) and its scope (co-author email lookup). The raw summary confirms the change adds type:user to the GitHub search and skips organization results in Searc…
Description check Passed The description states the problem (organizations matching co-author email searches), lists the changes (type:user in the query, ignoring returned organizations, new tests), and notes the testing appr…
Linked Issues check Passed Issue #5324 requires that a co-author email matching both a user and an organization resolve to the user. The head commit meets this in two ways. First, SearchGithubUserByEmail in cla-backend-go/git…
Out of Scope Changes check Passed The whole-PR diff against the merge base (6abee94) touches only cla-backend-go/github/github_repository.go and github_repository_test.go. Every changed hunk relates to issue #5324. The hunks are: the…
Full details: Title check

Explanation

The title names the fix (ignoring organizations) and its scope (co-author email lookup). The raw summary confirms the change adds type:user to the GitHub search and skips organization results in SearchGithubUserByEmail, so the title matches the main change.

Full details: Description check

Explanation

The description states the problem (organizations matching co-author email searches), lists the changes (type:user in the query, ignoring returned organizations, new tests), and notes the testing approach. This matches the changeset in cla-backend-go/github.

Full details: Linked Issues check

Explanation

Issue #5324 requires that a co-author email matching both a user and an organization resolve to the user. The head commit meets this in two ways. First, SearchGithubUserByEmail in cla-backend-go/github/github_repository.go now builds the query as %s in:email type:user, which removes organizations from the GitHub search. Second, if an organization is still returned, the function checks strings.EqualFold(user.GetType(), "Organization") and returns (nil, nil). A nil result sends the lookup to the database fallback, as the PR description states. The issue allows either approach, and the change uses both. The test file adds TestSearchGithubUserByEmailExcludesOrganizationsFromQuery, which asserts the exact query contact@example.com in:email type:user and checks that a user result is returned. It also adds TestSearchGithubUserByEmailIgnoresOrganizationResult, which asserts that an organization result yields a nil user with no error. Both automated tests cover the requirement. The strings package is already imported in the source file. The test helper newTestGithubClient is not added in this diff, so it must already exist in the package. The diff does not show its definition, so this is a minor unverified point.

Full details: Out of Scope Changes check

Explanation

The whole-PR diff against the merge base (6abee94) touches only cla-backend-go/github/github_repository.go and github_repository_test.go. Every changed hunk relates to issue #5324. The hunks are: the added doc comment, the type:user query change, the organization check that returns nil, the switch from result.Users[0].Login to user.GetLogin() in the log calls and return path, and the two new tests. The GetLogin() and GetType() accessors are nil-safe and do not change behavior for the user path. No unrelated behavior or file is changed.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: d0d88abb-5310-4f97-a5c3-2e8834feead5
Commits

Reviewing files that changed from the base of the PR and between 6abee94 and 3cc28a9.

Files selected for processing: 2

  • cla-backend-go/github/github_repository.go
  • cla-backend-go/github/github_repository_test.go

Included review availability: This review used your included allowance. 4 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are recorded for the co-author email lookup change.

No open issues 🎉

What changed in this PR

Fixes #5324 by preventing GitHub organizations from being selected during co-author email lookup in EasyCLA.

Changes:

  • Adds type:user to the GitHub email search query.
  • Ignores organization results so lookup can fall back to the database.
  • Adds tests for the query filter and organization-result handling.
File Description
cla-backend-go/​github/​github_repository.go Filters searches to users and rejects organization results.
cla-backend-go/​github/​github_repository_test.go Tests the search query and organization rejection.

Review effort: Balanced

@lfx-one lfx-one left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found no blocking or minor issues in this change. The search query now excludes organizations, and an organization that still comes back is ignored, so the lookup falls through to the database lookup. Both new tests cover those paths.

This pull request passed automated review, but its author isn't a verified member of the linuxfoundation GitHub organization, so I can't approve it. A maintainer needs to review and approve it before merge.

@SoulPancake

Copy link
Copy Markdown
Contributor Author

👋 @lukaszgryglicki
Would appreciate a review if possible

@SoulPancake

Copy link
Copy Markdown
Contributor Author

openfga/language#739 (comment)
As an example of where this bug comes up

@lukaszgryglicki lukaszgryglicki left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix @SoulPancake - LGTM.

Ran the new tests locally - both fail on dev and pass with this change, the rest of the github package passes too.

CI needs a maintainer approval to run on a fork - will approve it and merge once it is green.

@lukaszgryglicki

Copy link
Copy Markdown
Member

Also note that bots can be excluded from CLA checks via regexp.

@lukaszgryglicki
lukaszgryglicki merged commit 9bf2759 into linuxfoundation:dev Nov 24, 2026
8 checks passed
@SoulPancake
SoulPancake deleted the fix/co-author-org-match branch November 25, 2026 12:56

This branch had an error being deployed

1 failed deployment
dev — 3cc28a99 Deployed Nov 24, 2026 by lukaszgryglicki via build-deploy-dev #1107
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.

Co-author email can match an organization instead of a user

4 participants