DEVS-1317 Detect GitHub server-side force-with-lease rejection as a race condition#411
Merged
Merged
Conversation
…as a race condition The regex guarding the lease-rejected path only matched git's local rejection format (`[rejected] … stale info`), not GitHub's server-side format (`[remote rejected] … cannot lock ref`). Concurrent runs that lost the race were therefore treated as hard failures (setFailed) instead of expected skips (warning). Extend the regex and add a test that reproduces the exact stderr seen in the wild. Co-Authored-By: Claude <claude@anthropic.com>
Co-Authored-By: Claude <claude@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes AutoDev’s handling of git push --force-with-lease failures when GitHub rejects the push server-side during a concurrent-run race, ensuring the losing run emits a warning and remains green instead of failing the workflow.
Changes:
- Extend the “lease rejected / race condition” detection logic for push failures.
- Add a unit test that reproduces GitHub’s server-side
[remote rejected] ... cannot lock ref ...stderr format. - Update the compiled
dist/index.jsto reflect the source change.
Reviewed changes
Copilot reviewed 2 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/autodev.ts | Expands push-rejection detection to classify certain push failures as race conditions (warn, don’t fail). |
| src/autodev.test.ts | Adds a regression test for GitHub server-side [remote rejected] / cannot lock ref stderr. |
| dist/index.js | Compiled output updated to include the new rejection-detection logic. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ed-branch errors [remote rejected] matches too broadly — GitHub uses it for protected-branch hook declines and other non-race failures. Drop it from the pattern and rely solely on `cannot lock ref`, which is specific to the server-side ref-lock check that fires when force-with-lease loses a race. Co-Authored-By: Claude <claude@anthropic.com>
…d of broad substrings Use 'is at <sha> but expected <sha>' — the exact wording GitHub emits for a force-with-lease ref-lock failure — instead of the broad 'cannot lock ref' substring, which can also appear in unrelated local ref-lock errors. Co-Authored-By: Claude <claude@anthropic.com>
Co-Authored-By: Claude <claude@anthropic.com>
timdittler
approved these changes
Jun 3, 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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Fixes DEVS-1317
Type of Change
Description
When two AutoDev runs race to push to the same branch, the losing run should emit a warning and stay green. This worked when git rejected the push locally (
[rejected] … stale info), but failed when GitHub rejected it server-side:The substring
[rejected]does not appear in[remote rejected], so theleaseRejectedregex returnedfalse, theelsebranch calledsetFailed(), and the run turned red.Fix extends the regex with
\[remote rejected\]andcannot lock refto cover GitHub's server-side rejection format, and adds a test that reproduces the exact stderr observed in the wild (infrastructure repo, run #26835225245).Checklist
The changes and the PR were generated by Claude.