phase-pr must attach to an existing PR on Forgejo instead of failing on 409 #431
Labels
No labels
bug
contract
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
iterative-works/iw-cli#431
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
On a Forgejo remote, re-running
phase-pragainst a branch that already carriesan open PR fails instead of attaching to it and resuming the CI wait.
Observed on IW-422 phase 1:
./iw phase-pr --title "Phase 1: ..."created PR#424, then hit the tool's 10-minute timeout while waiting for CI. Re-running the
same command — the documented recovery — printed:
review-statestayed pinned atci_pendingand had to be moved toawaiting_reviewby hand, after reading CI withfj pr status 424 --wait.Root cause
The recovery path exists and is correct.
PhasePr.resolvePullRequestfalls backto the PR url recorded by the first invocation when it sees a duplicate-PR
failure. Its detection predicate is the problem:
ForgejoClientnever produces those words. Every failure is rendered as a barestatus code:
So Forgejo's duplicate-PR answer arrives as
Forgejo API error: 409,describesExistingreturns false, and the command errors out. GitHub and GitLabare unaffected — their clients say "already exists" in words.
Fix
Preferred: have
ForgejoClientcarry the response body into the error messageinstead of discarding it. Today every Forgejo failure loses its reason, not only
this one, so this repairs a whole class of unhelpful errors. Then
describesExistingmatches as intended.Narrower alternative: make
describesExistingrecognise the 409 status.Either way, add a test that drives the duplicate-PR path on the Forgejo backend —
there is none today, which is why this shipped.
Note on the skill
The
wf-implementation-workflowskill documents exit 3 as "run the same commandagain — it finds the pull request it already created and continues waiting."
That describes the intended behaviour correctly. The code does not match it on
Forgejo. Fix the code; the skill needs no change.
Why it matters
The window is worst in an unattended
batch-implementrun, where the exit-3loop is the documented recovery path and no human is present to move
review-stateby hand.Origin
Found while working IW-422 and recorded in its LESSONS.md; root cause identified
during lessons triage.