Skip to content

DEVS-1317 Detect GitHub server-side force-with-lease rejection as a race condition#411

Merged
0x46616c6b merged 5 commits into
mainfrom
DEVS-1317-fix-remote-rejected-lease-detection
Jun 3, 2026
Merged

DEVS-1317 Detect GitHub server-side force-with-lease rejection as a race condition#411
0x46616c6b merged 5 commits into
mainfrom
DEVS-1317-fix-remote-rejected-lease-detection

Conversation

@0x46616c6b

Copy link
Copy Markdown
Contributor

Fixes DEVS-1317

Type of Change

  • Bugfix

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:

! [remote rejected]  dev -> dev (cannot lock ref 'refs/heads/dev': is at dba12d5c but expected b051fd68)

The substring [rejected] does not appear in [remote rejected], so the leaseRejected regex returned false, the else branch called setFailed(), and the run turned red.

Fix extends the regex with \[remote rejected\] and cannot lock ref to 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

  • Write tests
  • Make sure all tests pass

The changes and the PR were generated by Claude.

0x46616c6b and others added 2 commits June 3, 2026 13:57
…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>
@0x46616c6b 0x46616c6b marked this pull request as ready for review June 3, 2026 12:02
@0x46616c6b 0x46616c6b requested a review from a team as a code owner June 3, 2026 12:02
@0x46616c6b 0x46616c6b requested review from axdotl and timdittler June 3, 2026 12:02
@timdittler timdittler requested a review from Copilot June 3, 2026 12:25

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.js to 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.

Comment thread src/autodev.ts
…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>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 4 changed files in this pull request and generated 1 comment.

Comment thread src/autodev.ts
0x46616c6b and others added 2 commits June 3, 2026 14:42
…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>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 4 changed files in this pull request and generated 1 comment.

Comment thread src/autodev.ts
@0x46616c6b 0x46616c6b merged commit ab3db7e into main Jun 3, 2026
12 checks passed
@0x46616c6b 0x46616c6b deleted the DEVS-1317-fix-remote-rejected-lease-detection branch June 3, 2026 14:23
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 3, 2026
@0x46616c6b 0x46616c6b added the bug Something isn't working label Jun 3, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants