Return null for unmergable heads rather than excepting#386
Open
mrginglymus wants to merge 5 commits intojenkinsci:masterfrom
Open
Return null for unmergable heads rather than excepting#386mrginglymus wants to merge 5 commits intojenkinsci:masterfrom
mrginglymus wants to merge 5 commits intojenkinsci:masterfrom
Conversation
Author
|
Having another look through the code, since the simplifications in #226 it may be that |
bitwiseman
reviewed
Apr 19, 2021
| PullRequestSCMRevision prRev = | ||
| createPullRequestSCMRevision(pr, prhead, listener, ghRepository); | ||
| prRev.validateMergeHash(); | ||
| try { |
Contributor
There was a problem hiding this comment.
We only need to do this if the prHead is a merge, right?
Maybe encapsulate this in a method and call from the two different places we currently call validateMergeHash()?
getValidatedMergeOrNull()?
bitwiseman
requested changes
Apr 19, 2021
Contributor
bitwiseman
left a comment
There was a problem hiding this comment.
This looks reasonable. A little refactoring suggested.
Also, can you create a test that exercises this? If not, I won't block the merge, but without a test there's no guarantee it won't break in the future. 😢
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.
Description
Triggered by jenkinsci/checks-api-plugin#83.
I have zombie jobs (job is aborted, but agents remain busy executing a dead job) seemingly triggered by the following stack trace:
The environmental behaviour that lead to this I believe was my force-pushing to the PR.
Now while there are separate issues in many different plugins that lead to this, the root exception in
validateMergeHashI believe should in fact be handled in its direct caller.This PR updates
github-branch-source-plugin/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSource.java
Line 1590 in ea3b723
nullif given an unmergeable PR head rather than excepting.This should not affect downstream consumers as this API is marked as
@CheckForNull.Note that this would bring it line with
github-branch-source-plugin/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSource.java
Line 1328 in ea3b723
which does return
nullfor unmergeable heads (despite the API not being marked@CheckForNull).I'm not certain that this is the best/correct way to solve this problem; I did look at fixing it in the
github-checks-apiplugin, but I did not want to leak the checking of this specific and ignorable issue across modules; asvalidateMergeHashonly throws a genericAbortExceptionit is indistinguishable from the many other uses ofAbortExceptionsthroughout this plugin.Submitter checklist
Reviewer checklist
Documentation changes
Users/aliases to notify
cc: @timja