fix: pr-lifecycle gives up on merge conflict (HTTP 405) instead of delegating rebase to agent #314

Closed
opened 2026-04-06 18:30:14 +00:00 by dev-bot · 0 comments
Collaborator

Problem

In lib/pr-lifecycle.sh lines 477-479, when pr_merge returns exit code 2 (HTTP 405 from Forgejo, meaning merge conflict), the walk sets merge_blocked and returns immediately:

if [ "$rc" -eq 2 ]; then
  _PR_WALK_EXIT_REASON="merge_blocked"
  return 1
fi

The rebase logic at lines 481-488 (which resumes the agent session and asks it to rebase + force-push) only runs for exit code 1 (other merge failures). HTTP 405 is exactly the case where a rebase is needed — the PR has conflicts with main.

Observed: PR #307 was approved with green CI but had conflicts from PRs that merged after it was created. The agent gave up with merge_blocked instead of rebasing.

Fix

Remove the early return for rc=2. Let it fall through to the rebase logic:

if [ "$rc" -eq 0 ]; then
  _PR_WALK_EXIT_REASON="merged"
  return 0
fi
# Merge failed (conflict or other) — ask agent to rebase
_prl_log "merge failed — invoking agent to rebase"
agent_run --resume "$session_id" --worktree "$worktree" ...

Affected files

  • lib/pr-lifecycle.sh (lines 477-479, remove early return on rc=2)

Acceptance criteria

  • HTTP 405 merge failure triggers agent rebase instead of blocking the issue
  • Agent rebases onto main, force-pushes, and the walk retries the merge
  • Other merge failures (not 405) also trigger the rebase path
## Problem In lib/pr-lifecycle.sh lines 477-479, when pr_merge returns exit code 2 (HTTP 405 from Forgejo, meaning merge conflict), the walk sets merge_blocked and returns immediately: if [ "$rc" -eq 2 ]; then _PR_WALK_EXIT_REASON="merge_blocked" return 1 fi The rebase logic at lines 481-488 (which resumes the agent session and asks it to rebase + force-push) only runs for exit code 1 (other merge failures). HTTP 405 is exactly the case where a rebase is needed — the PR has conflicts with main. Observed: PR #307 was approved with green CI but had conflicts from PRs that merged after it was created. The agent gave up with merge_blocked instead of rebasing. ## Fix Remove the early return for rc=2. Let it fall through to the rebase logic: if [ "$rc" -eq 0 ]; then _PR_WALK_EXIT_REASON="merged" return 0 fi # Merge failed (conflict or other) — ask agent to rebase _prl_log "merge failed — invoking agent to rebase" agent_run --resume "$session_id" --worktree "$worktree" ... ## Affected files - lib/pr-lifecycle.sh (lines 477-479, remove early return on rc=2) ## Acceptance criteria - [ ] HTTP 405 merge failure triggers agent rebase instead of blocking the issue - [ ] Agent rebases onto main, force-pushes, and the walk retries the merge - [ ] Other merge failures (not 405) also trigger the rebase path
dev-bot added the
backlog
priority
labels 2026-04-06 18:30:14 +00:00
dev-bot self-assigned this 2026-04-06 18:34:03 +00:00
dev-bot added
in-progress
and removed
backlog
labels 2026-04-06 18:34:03 +00:00
dev-bot removed their assignment 2026-04-06 18:44:03 +00:00
dev-bot removed the
in-progress
label 2026-04-06 18:44:03 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: disinto-admin/disinto#314
No description provided.