Skip to content

Conversation

uditagarwal97
Copy link
Contributor

@uditagarwal97 uditagarwal97 commented Jul 14, 2025

Problem
Currently, the email check workflow uses git to see email used for the last commit but the email address used when merging is actually governed by GitHub settings not what's stored in git. Due to this, the email check workflow passes even when the author's email is private in Github.
We saw several such cases in our fork of llvm. See intel/llvm#17675

Solution
Try to find user's email using GH's GraphQL APIs. User's email will be null if it's hidden in the profile.

@llvmbot
Copy link
Member

llvmbot commented Jul 14, 2025

@llvm/pr-subscribers-github-workflow

Author: Udit Kumar Agarwal (uditagarwal97)

Changes

Problem
Consider the following case:
Someone creates a PR with the signed commit but has email set to "private" in the Github UI (https://docs.github.com/en/account-and-profile/setting-up-and-managing-your-personal-account-on-github/managing-email-preferences/blocking-command-line-pushes-that-expose-your-personal-email-address). Currently, the email check workflow checkout to the branch and use git show -s --format='%ae' HEAD~0 to see email used for the last commit and the workflow will pass. However, when merging this PR, since the email is setting is private in Github UI, the merged PR will be authored with @<!-- -->noreply.github.com.
We saw several such cases in our fork of llvm. See intel/llvm#17675

Solution
This PR also checks for github.event.pull_request.user.email if it's NULL or not. If NULL, the PR will be merged with @<!-- -->noreply.github.com


Full diff: https://github.com/llvm/llvm-project/pull/148694.diff

1 Files Affected:

  • (modified) .github/workflows/email-check.yaml (+7-1)
diff --git a/.github/workflows/email-check.yaml b/.github/workflows/email-check.yaml
index 904ad718f97dd..35cbcd3c810eb 100644
--- a/.github/workflows/email-check.yaml
+++ b/.github/workflows/email-check.yaml
@@ -26,8 +26,11 @@ jobs:
           # Create empty comment file
           echo "[]" > comments
 
+      # If author's email is hidden in GH's settings, github.event.pull_request.user.email
+      # will be null and PR will be authored by noreply.github.com.
       - name: Validate author email
-        if: ${{ endsWith(steps.author.outputs.EMAIL, 'noreply.github.com')  }}
+        if: endsWith(steps.author.outputs.EMAIL, 'noreply.github.com') ||
+              github.event.pull_request.user.email == ''
         env:
           COMMENT: >-
             ⚠️ We detected that you are using a GitHub private e-mail address to contribute to the repo.<br/>
@@ -39,6 +42,9 @@ jobs:
           [{"body" : "$COMMENT"}]
           EOF
 
+          # Fail this job.
+          false
+
       - uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 #v4.3.0
         if: always()
         with:

Copy link

⚠️ We detected that you are using a GitHub private e-mail address to contribute to the repo.
Please turn off Keep my email addresses private setting in your account.
See LLVM Developer Policy and LLVM Discourse for more information.

@uditagarwal97
Copy link
Contributor Author

Here's an example of a PR (at llvm/llvm-project) where this workflow is passing but the PR was merged with noreply.github.com email: #148617

@uditagarwal97 uditagarwal97 marked this pull request as draft July 14, 2025 18:30
Copy link

⚠️ We detected that you are using a GitHub private e-mail address to contribute to the repo.
Please turn off Keep my email addresses private setting in your account.
See LLVM Developer Policy and LLVM Discourse for more information.

5 similar comments
Copy link

⚠️ We detected that you are using a GitHub private e-mail address to contribute to the repo.
Please turn off Keep my email addresses private setting in your account.
See LLVM Developer Policy and LLVM Discourse for more information.

Copy link

⚠️ We detected that you are using a GitHub private e-mail address to contribute to the repo.
Please turn off Keep my email addresses private setting in your account.
See LLVM Developer Policy and LLVM Discourse for more information.

Copy link

⚠️ We detected that you are using a GitHub private e-mail address to contribute to the repo.
Please turn off Keep my email addresses private setting in your account.
See LLVM Developer Policy and LLVM Discourse for more information.

Copy link

⚠️ We detected that you are using a GitHub private e-mail address to contribute to the repo.
Please turn off Keep my email addresses private setting in your account.
See LLVM Developer Policy and LLVM Discourse for more information.

Copy link

⚠️ We detected that you are using a GitHub private e-mail address to contribute to the repo.
Please turn off Keep my email addresses private setting in your account.
See LLVM Developer Policy and LLVM Discourse for more information.

Signed-off-by: Agarwal, Udit <[email protected]>
@uditagarwal97 uditagarwal97 force-pushed the private/udit/email_check branch from daf6fc6 to bbde668 Compare July 14, 2025 22:36
Copy link

⚠️ We detected that you are using a GitHub private e-mail address to contribute to the repo.
Please turn off Keep my email addresses private setting in your account.
See LLVM Developer Policy and LLVM Discourse for more information.

Copy link

⚠️ We detected that you are using a GitHub private e-mail address to contribute to the repo.
Please turn off Keep my email addresses private setting in your account.
See LLVM Developer Policy and LLVM Discourse for more information.

@uditagarwal97
Copy link
Contributor Author

uditagarwal97 commented Jul 14, 2025

PR is ready for review.
Workflow run when email is hidden: https://github.com/llvm/llvm-project/actions/runs/16279434976/job/45965879699
Workflow run when email is public: https://github.com/llvm/llvm-project/actions/runs/16279496749/job/45966062207

Based on contribution history, tagging @asl @DavidSpickett @vbvictor for feedback.

@uditagarwal97 uditagarwal97 marked this pull request as ready for review July 14, 2025 22:52
@asl
Copy link
Collaborator

asl commented Jul 15, 2025

This looks reasonable to me @tstellar @DavidSpickett @boomanaiden154 any objections?

Copy link
Collaborator

@DavidSpickett DavidSpickett left a comment

Choose a reason for hiding this comment

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

My understanding of this is that before we looked at the commit and if that had a valid email address, that's enough.

The problem is that the email address used when merging is actually governed by GitHub settings not what's stored in git.

So this changes to GraphQL to do the check, but for the PR author, the way to make the email public is the same as before.

Correct?

(I ask you to confirm because at first glance the description feels like 2 layers of settings but in fact, one of them, the actual git commit, is ignored by GitHub)

Copy link
Contributor

@boomanaiden154 boomanaiden154 left a comment

Choose a reason for hiding this comment

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

Is there documentation on what the GraphQL query is supposed to return given the different settings?

I know Github lets me select from multiple emails when merging. I'm not sure if there's a default or how it gets setup and I would be more comfortable approving this patch with a better understanding of how these all interact.

@uditagarwal97
Copy link
Contributor Author

Is there documentation on what the GraphQL query is supposed to return given the different settings?

I know Github lets me select from multiple emails when merging. I'm not sure if there's a default or how it gets setup and I would be more comfortable approving this patch with a better understanding of how these all interact.

@boomanaiden154
I think GraphQL returns your default public email. Here's an experiment I did:

Workflow run after I changed my default public email: https://github.com/llvm/llvm-project/actions/runs/16300461944/job/46033416527?pr=148694#step:3:24 (compare it with the previous run https://github.com/llvm/llvm-project/actions/runs/16279496749/job/45966062207)
Changing my default public email also changes the email returned by GraphQL.

Regarding official documentation, the closest one I found is: https://docs.github.com/en/graphql/reference/objects#user
user.email returns the user's publicly visible profile email.

Copy link
Contributor

@boomanaiden154 boomanaiden154 left a comment

Choose a reason for hiding this comment

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

Workflow run after I changed my default public email: https://github.com/llvm/llvm-project/actions/runs/16300461944/job/46033416527?pr=148694#step:3:24 (compare it with the previous run https://github.com/llvm/llvm-project/actions/runs/16279496749/job/45966062207)
Changing my default public email also changes the email returned by GraphQL.

Regarding official documentation, the closest one I found is: https://docs.github.com/en/graphql/reference/objects#user
user.email returns the user's publicly visible profile email.

That looks good to me. I can't imagine anything other than the default email would be used when merging a PR for someone.

@DavidSpickett
Copy link
Collaborator

I think @boomanaiden154 has the technical aspects covered, they can be the approver.

The new description is much clearer, thankyou!

Due to this, the email check workflow passes even when the author's email is private in Github.

This might explain why I've seen a number of noreply addresses slip through.

@uditagarwal97
Copy link
Contributor Author

This might explain why I've seen a number of noreply addresses slip through.

Orthogonal to this PR, why don't we cause the workflow to fail when user's email is private? That way, the gatekeepers will be aware of the use of private emails? IMO, just adding a comment is not sufficient and it might get missed by the gatekeepers/reviewers say, when the PR received many comments.

@boomanaiden154
Copy link
Contributor

Orthogonal to this PR, why don't we cause the workflow to fail when user's email is private? That way, the gatekeepers will be aware of the use of private emails? IMO, just adding a comment is not sufficient and it might get missed by the gatekeepers/reviewers say, when the PR received many comments.

Not entirely sure. I think I remember there being some discussion about that on the original PR/some follow up commits. I agree that it would probably be good to make the workflow fail rather than just leaving a comment.

That should probably be done as part of a separate patch though.

@uditagarwal97
Copy link
Contributor Author

Orthogonal to this PR, why don't we cause the workflow to fail when user's email is private? That way, the gatekeepers will be aware of the use of private emails? IMO, just adding a comment is not sufficient and it might get missed by the gatekeepers/reviewers say, when the PR received many comments.

Not entirely sure. I think I remember there being some discussion about that on the original PR/some follow up commits. I agree that it would probably be good to make the workflow fail rather than just leaving a comment.

That should probably be done as part of a separate patch though.

I'll create a separate PR to make the workflow fail

Copy link
Contributor

@boomanaiden154 boomanaiden154 left a comment

Choose a reason for hiding this comment

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

Everything appears to be working with the ephemeral token?

@sarnex sarnex merged commit 0f03050 into llvm:main Jul 16, 2025
8 of 9 checks passed
@uditagarwal97 uditagarwal97 deleted the private/udit/email_check branch July 16, 2025 17:13
sarnex pushed a commit that referenced this pull request Jul 16, 2025
…ivate in Github UI" (#149186)

Reverts #148694

The workflow is failing if user's email is not listed publicly on your
GH profile. This is different from not having your email public on
Github (in Github email settings page vs. email field in Github
profile/email settings).
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Jul 16, 2025
…email is private in Github UI" (#149186)

Reverts llvm/llvm-project#148694

The workflow is failing if user's email is not listed publicly on your
GH profile. This is different from not having your email public on
Github (in Github email settings page vs. email field in Github
profile/email settings).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants