280: MR creation not idempotent on resume — GitLab 409 when re-running after auto-merge failure #281
Loading…
Reference in a new issue
No description provided.
Delete branch "feature/issue-280/mr-creation-not-idempotent-on-resume-gitlab-409-wh"
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?
Summary
Fixes #280: after #274's
glab mr view --jsonbug aborted themrstage during auto-merge polling (i.e. after the MR was already created), resuming re-rancreateMr()and hit a duplicate-create error (GitLab409, GitHub422, Forgejo equivalent).Fix (both parts, as requested)
Idempotent
createMracross resumefindExistingMr()method on theMrClientinterface (src/mr/types/mrClient.ts)runMrStagechecksfindExistingMr()before callingcreateMr()and reuses an already-open MR/PR instead of creating a duplicatecreateMr()directly when a client doesn't implementfindExistingMr(backward-compatible interface)Two-phase
mr-result.jsonpersistencemr-result.jsonis now written immediately aftercreateMr()succeeds, withautoMerge: { enabled: true, merged: false }, before auto-merge polling/merging beginsdetermineResumeStage.ts/isMrResultAutoMergeComplete) treatsmerged: falseas an incomplete mr stage, so a crash during polling causes resume to skip straight to polling/merge instead of re-creating the MR/PRDocs
AGENTS.md,DESIGN.md,IMPLEMENTATION_PLAN.mdupdated to cross-reference the new idempotency behavior and two-phase artifact writeAcceptance criteria
createMr()for a branch with an already-open MR/PR reuses it instead of failing (GitLab 409 / GitHub 422 / Forgejo equivalent) — unit-tested per platformmr-result.json;DESIGN.md/IMPLEMENTATION_PLAN.md/tests updated togethernpm run lint,npm test(2030 tests), andnpm run buildall passRelated
glab mr view --jsonbug that originally triggered this failure path)