From e574d180ed4faebe12b6c0f5d9fd9c68f5d4f194 Mon Sep 17 00:00:00 2001 From: Steven Roberts Date: Thu, 20 Aug 2026 19:23:31 -0700 Subject: [PATCH] Only reuse an OPEN pull request when re-applying an issue `gh pr view ` 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 --- .github/workflows/issue-to-pr.yml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/issue-to-pr.yml b/.github/workflows/issue-to-pr.yml index cb790df..75c22ac 100644 --- a/.github/workflows/issue-to-pr.yml +++ b/.github/workflows/issue-to-pr.yml @@ -164,11 +164,20 @@ jobs: # An edited issue re-runs this job; update the existing PR instead of # failing on a duplicate. - if gh pr view "$BRANCH" --json number >/dev/null 2>&1; then - gh pr edit "$BRANCH" \ + # + # It has to be an OPEN pr. `gh pr view ` resolves a closed one + # just as happily, so once an issue's pr had been closed this took the + # update path forever: it force-pushed a correctly rebuilt branch, ran + # `gh pr edit` against the closed pr, printed "updated", and exited 0 + # without ever opening anything. Issue #9 sat in that state through + # two replay attempts, each reporting success. + EXISTING=$(gh pr list --head "$BRANCH" --state open --limit 1 \ + --json number --jq '.[].number') + if [ -n "$EXISTING" ]; then + gh pr edit "$EXISTING" \ --title "$TITLE" \ --body-file "$RUNNER_TEMP/pr/pr_body.md" - URL=$(gh pr view "$BRANCH" --json url --jq .url) + URL=$(gh pr view "$EXISTING" --json url --jq .url) echo "updated $URL" else URL=$(gh pr create \