Skip to content

default-workflow step 4 is not rerun-safe when branch/worktree already exists #3023

@rysweet

Description

@rysweet

Summary

When default-workflow is re-run after a partial failure, step-04-setup-worktree can fail hard if the derived branch already exists locally or remotely.

Reproduction

In a rerun of default-workflow for qa-team remediation, Step 4 failed with:

fatal: a branch named 'feat/issue-3-recipevartaskdescription' already exists

After removing the local worktree/branch and rerunning, Step 4 failed again on push with:

! [rejected] feat/issue-3-recipevartaskdescription -> feat/issue-3-recipevartaskdescription (non-fast-forward)

Expected

  • The workflow should handle reruns safely.
  • If a branch/worktree already exists, it should either reuse it intentionally, clean it up safely, or generate a unique recovery branch name.
  • Remote push conflicts should be handled explicitly rather than aborting the whole workflow.

Actual

  • A stale local branch/worktree or remote branch causes Step 4 to fail before any remediation work can proceed.

Suggested Fix

  • Detect existing local worktrees/branches before git worktree add -b ....
  • Detect existing remote branch before push.
  • Add an explicit rerun/recovery path (reuse existing branch, or generate a unique suffix).
  • Surface the recovery decision in recipe output.

Impact

  • Recipe reruns are brittle
  • Failed runs leave behind state that blocks subsequent runs
  • Users have to do manual git cleanup outside the workflow to continue

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions