fix(push-hook): retry MR commits fetch to handle GitLab async race condition#174
Merged
pfongkye merged 1 commit intoJun 5, 2026
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #174 +/- ##
==========================================
+ Coverage 89.29% 89.36% +0.07%
==========================================
Files 104 105 +1
Lines 2269 2295 +26
Branches 440 444 +4
==========================================
+ Hits 2026 2051 +25
- Misses 230 231 +1
Partials 13 13 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
pfongkye
reviewed
Jun 5, 2026
pfongkye
reviewed
Jun 5, 2026
6c92c80 to
84da116
Compare
…ndition When Homer receives a push hook, it filters the pushed commits by cross-referencing the GitLab MR commits API to remove rebase noise. Because GitLab updates MR content asynchronously, the just-pushed commit is sometimes absent from the API response at the time Homer fetches it, causing a silent 204 with no Slack notification. Fix: poll the MR commits endpoint (up to 5s, 1s intervals) until at least one pushed commit appears. Network errors and non-2xx responses (which callAPI resolves as non-arrays) are both retried. Falls back to the last known valid result on timeout, ensuring a graceful 204 rather than a 500. Note: an ack-first design (respond 200 immediately, then process) would remove the webhook timeout concern entirely and allow a more generous retry window — left as a future improvement.
84da116 to
0b784dc
Compare
pfongkye
approved these changes
Jun 5, 2026
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.
Problem
When Homer receives a push hook, it filters the pushed commits by cross-referencing the GitLab MR commits API — this removes rebase noise by keeping only commits that actually belong to the MR.
The issue: GitLab updates MR content asynchronously. Right after a push, the just-pushed commit is sometimes absent from the MR commits API response at the time Homer fetches it. The intersection is empty, the handler silently returns 204, and no Slack notification is sent. No error is logged, making it invisible.
Fix
Introduce
waitForMergeRequestCommits, a utility that polls the MR commits endpoint until at least one pushed commit appears, then returns. It follows the same pattern as the existingwaitForReleasePipeline.Trade-offs
Changes
src/review/commands/share/utils/waitForMergeRequestCommits.ts— new polling utilitysrc/review/commands/share/hookHandlers/pushHookHandler.ts— use the new utility__tests__/review/waitForMergeRequestCommits.test.ts— unit tests covering: immediate hit, retry-until-found, error retry, timeout__tests__/review/pushHook.test.ts— one-line update: the "no related review" test now correctly gets its 204 from no review in DB (the retry logic is owned by the unit tests above)