Skip to content

Only reuse an OPEN pull request when re-applying an issue - #77

Merged
sr320 merged 1 commit into
mainfrom
fix/reopen-closed-pr
Aug 21, 2026
Merged

Only reuse an OPEN pull request when re-applying an issue#77
sr320 merged 1 commit into
mainfrom
fix/reopen-closed-pr

Conversation

@sr320

@sr320 sr320 commented Aug 21, 2026

Copy link
Copy Markdown
Member

Found by running the replay. Issue #9 timed out twice with the workflow reporting success both times.

What happens

if gh pr view "$BRANCH" --json number >/dev/null 2>&1; then   # matches CLOSED prs too

gh pr view inv/issue-9 resolves to PR #13 — closed on 2026-08-06. So the workflow takes the "update the existing PR" path, and from the run log:

+ 6c3b166...e81860c inv/issue-9 -> inv/issue-9 (forced update)
updated https://github.com/RobertsLab/lab-inventory/pull/13

It force-pushed a correctly rebuilt branch, edited a closed PR, and exited 0. Once an issue's PR has been closed, that issue can never produce a new one again.

The run is green in every respect. The only way to notice is to go looking for a PR that isn't there — which is exactly what replay_issues.py does instead of trusting the run, and why it caught this.

The fix

gh pr list --head "$BRANCH" --state open — the check this code always meant. Verified against the live repo:

branch existing PR --state open match
inv/issue-9 #13 closed (empty) → creates a new one
inv/issue-15 #75 merged (empty) → creates a new one

Affects three issues

#9, #10 and #65 — the ones whose PRs were closed rather than merged. Their branches are already rebuilt and correct from the failed attempts; they just need re-triggering once this lands.

🤖 Generated with Claude Code

`gh pr view <branch>` resolves a closed pull request as readily as an open
one, so once an issue's pr had been closed, issue-to-pr took the "update
the existing pr" path forever. It force-pushed a correctly rebuilt
branch, ran `gh pr edit` against the closed pr, printed "updated", and
exited 0 -- without opening anything.

The workflow run is green in every respect. The only way to notice is to
go looking for a pull request that isn't there.

Found by replay_issues.py, which timed out twice on issue #9 rather than
believing the run: the branch had been rebuilt (6c3b166..e81860c, forced)
and the log read "updated .../pull/13", a pr closed on 2026-08-06. #10
and #65 are in the same state.

`gh pr list --head "$BRANCH" --state open` is the check that means what
this code intended.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@sr320
sr320 requested a review from kubu4 as a code owner August 21, 2026 02:23
@sr320
sr320 merged commit cbe7997 into main Aug 21, 2026
2 checks passed
@sr320
sr320 deleted the fix/reopen-closed-pr branch August 21, 2026 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant