ci(auto-update): wait for state to settle and surface real errors#5958
Merged
MarkusNeusinger merged 1 commit intomainfrom May 7, 2026
Merged
ci(auto-update): wait for state to settle and surface real errors#5958MarkusNeusinger merged 1 commit intomainfrom
MarkusNeusinger merged 1 commit intomainfrom
Conversation
The first run after #5957 merged found 0 BEHIND PRs even though three PRs were stuck behind main. Two issues: 1. The workflow runs ~4s after the push to main, but GitHub recomputes `mergeStateStatus` and the cached PR head SHA asynchronously. Right after the push the field can still be "UNKNOWN" and the cached head can be stale. Add a 30s sleep at the start so GitHub has time to settle. 2. The script filtered for `mergeStateStatus == "BEHIND"` and skipped UNKNOWN candidates — exactly the ones we wanted to fix. Drop the filter: after a push to main, every open auto-merge PR is by definition behind, and update-branch is a no-op when the head is already up-to-date. Also: - Bump permissions to `contents: write` since update-branch creates a merge commit on the head ref. - Drop `--silent` and capture stderr so the actual GitHub error (conflict, SHA mismatch, etc.) lands in the workflow log instead of the generic "likely conflict or stale ref" guess. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts the Auto-update PR branches workflow to more reliably update auto-merge PR branches immediately after main advances, avoiding missed updates caused by GitHub’s asynchronous recomputation of PR merge state / cached head SHAs and improving error visibility in logs.
Changes:
- Add an initial 30s delay to allow PR mergeability/head SHA state to settle after a push to
main. - Iterate all open PRs with auto-merge enabled (instead of filtering strictly on
mergeStateStatus == BEHIND), avoiding skips when the status is temporarilyUNKNOWN. - Increase workflow token permissions to allow
update-branchwrites and capture/log realgh apierrors (stderr) instead of suppressing them.
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.
Summary
First run of `auto-update-pr-branches.yml` after #5957 found 0 BEHIND PRs even though three were stuck behind main (#5916, #5870, #5902). Two issues:
Also:
Verified manually: calling `PUT /pulls/{num}/update-branch` from the CLI on #5916 and #5870 worked and they auto-merged within seconds. The 422 on #5902 was a real history-divergence conflict (4 ahead / 58 behind / merge_base differs) — separate problem.
Test plan