Skip to content

fix: a PR claim check that runs after the merge writes nothing (Fixes #36) - #37

Merged
vpacher merged 2 commits into
masterfrom
fix/36-merged-pr-claim-race
Nov 25, 2026
Merged

vpacher merged 2 commits into
masterfrom
fix/36-merged-pr-claim-race

Conversation

@vpacher

@vpacher vpacher commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Fixes #36

The PR claim check took the PR's open state from the event payload. Claim bot run 45615324507 (pull_request: edited, queued at 12:36:08) started after #35 had merged at 12:36:20, which also shut issue 34. It reported obs-rust/.github#34 is closed, labelled the merged PR claim-conflict, posted the conflict comment and failed. (#35 cleaned up by hand: label removed, comment hidden as outdated.)

Change

on_pull_request (workflow/claim_bot.py) now reads the PR's live issue object before it checks conflicts. When the PR is closed (merged or closed), it logs that and passes without a write. The read already happened in every run, only later, so the change adds no API call.

RED → GREEN

  • RED cb8ab1c: tests/test_pr_claims.py, test_an_event_that_runs_after_the_merge_writes_nothing. It builds an edited event, then merges the PR and closes its issue before the check runs. It fails: the check returns False and labels the merged PR.
  • GREEN 1cc31bd: passes. The 403 tests in tests/test_claim_bot_errors.py mock the PR object, so they now set closed=False.

Local checks

$ uv run python -m unittest discover -s tests -t .
Ran 262 tests in 0.489s
OK
$ uvx ruff format --check workflow/claim_bot.py tests/test_pr_claims.py tests/test_claim_bot_errors.py
3 files already formatted

ruff check reports only UP017 in main, which is on master already.

Note for merging: do not edit this PR right before the merge. With this fix in master that is harmless, but this PR's own claim check still runs the old code until it merges.

🤖 Generated with Claude Code

vpacher and others added 2 commits November 25, 2026 13:42
)

An `edited` event queued before #35 merged ran after the merge had
closed #34 (Claim bot run 45615324507). It read `open` from the event
payload, saw #34 closed, labelled the merged PR claim-conflict, posted
the conflict comment and failed. This test merges the PR and closes its
issue before the queued event runs and expects no write and a pass.

Fails now: on_pull_request returns False and labels the merged PR.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…36)

on_pull_request took the PR's open state from the event payload. A run
that waited for a runner can start after the merge, which has already
closed the issues the PR fixes, and then reported a false "is closed"
conflict on the merged PR (#35, run 45615324507). It now reads the PR's
live state first and passes without a write when the PR is closed.

The 403 tests mock the PR object, so they now give it closed=False.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added the claim-conflict A PR closing reference conflicts with the issue claim label Nov 25, 2026
@github-actions

This comment has been minimized.

@github-actions github-actions Bot removed the claim-conflict A PR closing reference conflicts with the issue claim label Nov 25, 2026

@vpacher vpacher left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Coordinator review: no blocking findings.

  • Correctness: the live PR state is read before conflicts(); a closed or merged PR passes with no write. In production issue() reads repos/{repo}/issues/{n} over REST (not through ghcache), where a merged PR is closed, so the guard sees the merge.
  • Cost: the same gh.issue() call ran in every run before, only later; no extra API call.
  • Tests: RED cb8ab1c reproduces the #35 timeline (event built, then merge and issue close, then the check) and fails; GREEN passes all 262. The 403 mocks get closed=False. PR CI test and claim are green.
  • Claim: #36 is assigned and ready with an accepted Claiming: comment.

The first claim run failed correctly: the description's prose "closed #34" was a closing keyword. Reworded; the annotation from #35 named the cause.

@vpacher
vpacher merged commit 44e70bc into master Nov 25, 2026
3 of 4 checks passed
@vpacher
vpacher deleted the fix/36-merged-pr-claim-race branch November 25, 2026 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

claim bot: a queued PR event that runs after the merge reports a false conflict on the merged PR

1 participant