fix(gh): fix re-run button on Pull Requests#2597
Conversation
|
/gemini review |
There was a problem hiding this comment.
Pull request overview
This PR fixes GitHub check_run / check_suite “rerequested” handling for fork PRs where the webhook payload can have head_branch: null and an empty pull_requests list, by falling back to resolving the PR via commit SHA instead of misclassifying the event as a push.
Changes:
- Update GitHub payload parsing to resolve PR rerequests by commit SHA when
head_branchis missing. - Add unit tests covering the new SHA-resolution behavior and the error case when no PR is found.
- Extend the GitHub GHE e2e rerequest test to exercise the null-
head_branchcheck_runscenario; add a new JSON fixture.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
pkg/provider/github/parse_payload.go |
Adds SHA-based PR lookup fallback for rerequest events when head_branch is missing. |
pkg/provider/github/parse_payload_test.go |
Adds unit tests for null-head_branch rerequest behavior (success + failure). |
test/github_pullrequest_rerequest_test.go |
Adds an e2e scenario sending a check_run rerequest with null head_branch and empty PR list. |
test/fixtures/check_suite_rerequest_null_branch.json |
Adds a fixture representing a null-head_branch check_suite/check_run rerequest payload. |
Comments suppressed due to low confidence (1)
pkg/provider/github/parse_payload.go:495
- In the check_run rerequest fallback where this is treated as a push event,
runevent.TriggerTargetis never set (unlikehandleCheckSuites, which sets it to "push"). Downstream logic (e.g., changed-files fetching/switches on TriggerTarget) may treat an empty TriggerTarget as unknown and skip important behavior. Setrunevent.TriggerTarget = triggertype.Push(or "push") alongsiderunevent.EventType = "push"for consistency.
runevent.BaseBranch = runevent.HeadBranch
runevent.BaseURL = runevent.HeadURL
runevent.EventType = "push"
// we allow the rerequest user here, not the push user, i guess it's
// fine because you can't do a rereq without being a github owner?
runevent.Sender = event.GetSender().GetLogin()
v.userType = event.GetSender().GetType()
return runevent, nil
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Review from Gemini CodeI've taken a deep look at this pull request. Here is my assessment: The Problem: The Fix: Testing:
Conclusion: |
98e1889 to
7c8d958
Compare
|
/test linters |
|
/cancel linters |
|
/retest |
|
@zakisk I updated the fix based on your review. For the null I also removed the extra here is my recording of my test: recording-20260331-14h04.mp4 |
7c8d958 to
0217de3
Compare
0217de3 to
38df0c5
Compare
38df0c5 to
04e597b
Compare
322557a to
618af76
Compare
@chmouel this looks good to me but may be document this behavior then? |
GitHub check_run and check_suite rerequests for fork PRs can have a null head_branch and an empty pull_requests list. PAC was falling back to treating these events as push events, causing the Re-run button on PRs to have no effect. When head_branch is null, fall back to looking up the associated PR by commit SHA before deciding the event type. If a PR is found, process as a PR rerequest. If not, return a clear error. Signed-off-by: Chmouel Boudjnah <chmouel@redhat.com>
c025f1f to
375cb58
Compare
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2597 +/- ##
==========================================
+ Coverage 58.47% 58.73% +0.25%
==========================================
Files 205 206 +1
Lines 19625 20296 +671
==========================================
+ Hits 11476 11920 +444
- Misses 7434 7611 +177
- Partials 715 765 +50 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
i think that's a bit too low level to document? that and i don't imagine a lot of peolple have PR with multiple related commit that is not merged on HEAD (it usually a rebase so it would not see it as first) |
📝 Description of the Change
GitHub check_run and check_suite rerequests for fork PRs can have
a null head_branch and an empty pull_requests list. PAC was falling
back to treating these events as push events, causing the Re-run
button on PRs to have no effect.
When head_branch is null, fall back to looking up the associated PR
by commit SHA before deciding the event type. If a PR is found,
process as a PR rerequest. If not, return a clear error.
output.mp4
🔗 Linked Issue
Jira https://redhat.atlassian.net/browse/SRVKP-11161
🧪 Testing Strategy
🤖 AI Assistance
AI assistance can be used for various tasks, such as code generation,
documentation, or testing.
Please indicate whether you have used AI assistance
for this PR and provide details if applicable.
Important
Slop will be simply rejected, if you are using AI assistance you need to make sure you
understand the code generated and that it meets the project's standards. you
need at least know how to run the code and deploy it (if needed). See
startpaac to make it easy
to deploy and test your code changes.
If the majority of the code in this PR was generated by an AI, please add a
Co-authored-bytrailer to your commit message.For example:
Co-authored-by: Claude noreply@anthropic.com
✅ Submitter Checklist
fix:,feat:) matches the "Type of Change" I selected above.make testandmake lintlocally to check for and fix anyissues. For an efficient workflow, I have considered installing
pre-commit and running
pre-commit installtoautomate these checks.