github-branch-source-plugin
github-branch-source-plugin copied to clipboard
[JENKINS-75704] Fix Copilot user null name/email handling
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:
- If a pull request is authored by a user with login
"copilot", a syntheticContributorMetadataActionis created with:- Name:
"copilot" - Email:
"[email protected]"
- Name:
- This ensures PRs from Copilot are processed and visible, even though "copilot" is not a real GitHub user.
- If a pull request is authored by a user with login
-
Other users:
- For all other users, the contributor metadata is still created using the values returned by the GitHub API (
login,name, andemail) with no fallback.
Ifuser.getName()oruser.getEmail()arenull, those fields will remainnullas before.
- For all other users, the contributor metadata is still created using the values returned by the GitHub API (
-
Unchanged logic for missing users:
- If the user does not exist (for example, if the API returns 404), the PR is still ignored just like before.
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
- [x] Link to JIRA ticket in description, if appropriate.
- [x] Change is code complete and matches issue description
- [x] Automated tests have been added to exercise the changes
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.
- [x] Reviewer's manual test instructions provided in PR description. See Reviewer's first task below.
Reviewer checklist
- [ ] Run the changes and verify that the change matches the issue description
- [ ] Reviewed the code
- [ ] Verified that the appropriate tests have been written or valid explanation given
Documentation changes
- [ ] Link to jenkins.io PR, or an explanation for why no doc changes are needed
Users/aliases to notify
Fallback for missing user name or email:
* For all other users, if `user.getName()` or `user.getEmail()` are `null` or throw exceptions, the code now defaults to: * Name: `user.getLogin()` * Email: `user.getLogin() + "@unknown.user"` * This prevents exceptions when processing PRs or commits from bot users or users with incomplete profiles.
I see no evidence of such a change in the current patch; did you revert it? If so, please update the PR description accordingly.
Dear @jglick and @IvanGasant , Do you have an estimated timeline for merging this pull request and creating a new release? I'm particularly interested in this fix, as it's currently blocking some of our Jenkins CI/CD workflows when Copilot creates pull requests in our repositories.
Thank you!
Hey @IvanGasant , thanks a lot for your contribution! Hey @jglick , @jenkinsci/github-plugin-owners , @jenkinsci/github-branch-source-plugin-developers , could you please merge this PR? The issue is currently impacting our Jenkins pipelines and breaking our CI/CD flow. Thank you so much!
It's true that Jesse did approve the pull request but a few comments were not addressed, specifically about retaining the comments, for future reviewers.
It's true that Jesse did approve the pull request but a few comments were not addressed, specifically about retaining the comments, for future reviewers.
Thank you Adrien for your reply. Hey @IvanGasant , hola! Would it be possible for you to address the pending comments so we can expedite your code to be merged? Muchas gracias!
It would be nice if @IvanGasant could manage the comments to merge this PR. The fix helps us use Copilot in systems with Jenkins in their pipelines.
we are running into this issue as well, is there any way around it until this get merged and released ?
Hi everyone, thank you for your comments and for your interest in this PR. Apologies for the delay in progressing with this—it’s been a busy period for me, but I plan to resume work on it soon. I’ll make sure to address all suggestions and questions raised and will keep you updated on my progress. If there’s any particular priority or information you need, please let me know.
Thanks again for your patience!
Ready for Review @jglick
I am not maintaining this plugin, will leave it some other maintainer.