-
Notifications
You must be signed in to change notification settings - Fork 374
[JENKINS-75704] Fix Copilot user null name/email handling #864
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…pdate tests - Updated logic so that only the copilot user is allowed to bypass missing name and email checks in pull request processing. - All other users without name/email are marked as unknown and a log message is generated. - Added and updated tests to verify that copilot is accepted and handled as expected.
I see no evidence of such a change in the current patch; did you revert it? If so, please update the PR description accordingly. |
@@ -2572,17 +2572,22 @@ public void observe(GHPullRequest pr) { | |||
GHUser user = null; | |||
try { | |||
user = pr.getUser(); | |||
if (users.containsKey(user.getLogin())) { | |||
// looked up this user already |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
may as well retain this comment in the else
clause
ContributorMetadataAction contributor = | ||
new ContributorMetadataAction(user.getLogin(), user.getName(), user.getEmail()); | ||
pullRequestContributorCache.put(number, contributor); | ||
// store the populated user record now that we have it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
} catch (FileNotFoundException e) { | ||
// If file not found for user, warn but keep going |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC this was just false.
Description
This PR improves the handling of pull requests and commits authored by GitHub IA, Copilot, who may not have a real GitHub account or may lack a defined name or email.
It prevents exceptions and ensures that these contributions are not discarded during indexing or processing.
Changes
Special handling for the "copilot" user:
ContributorMetadataAction
is created with:"copilot"
"[email protected]"
Fallback for missing user name or email:
user.getName()
oruser.getEmail()
arenull
or throw exceptions, the code now defaults to:user.getLogin()
user.getLogin() + "@unknown.user"
Preserves previous logic for truly missing users:
Motivation
GitHub Copilot and other bots can appear as authors of commits and pull requests, but may not exist as real users in GitHub.
Without this special handling, such PRs would be discarded or cause exceptions, impacting the visibility and traceability of AI-generated or bot-generated contributions.
See JENKINS-75704 for further information.
Submitter checklist
No automated tests were added because this is a trivial change: it only handles null values or exceptions when fetching the GitHub user's name/email for logging purposes, defaulting to safe values if missing. It does not affect business logic or the core functionality of the plugin.
Reviewer checklist
Documentation changes
Users/aliases to notify