Bug
implement_task fails on the first implementation pass (before any PR is created) with two cascading errors:
git fetch fork — "fatal: 'fork' does not appear to be a git repository"
Cannot recreate workspace for <TICKET>: missing branch_name, current_repo, fork_owner, or fork_repo in state
If the workspace survives and the fetch error is bypassed, a second failure occurs after the container completes successfully:
git push -u fork <branch> — "fatal: 'fork' does not appear to be a git repository"
Root cause
Commit 7ebb8b7 ("fix: persist review handoffs across workers", PR #168) added prepare_workspace() and push_to_fork_with_retry() calls to implement_task(). Both assume a fork remote already exists. On the first implementation pass the fork is not created until create_pull_request, so fork_owner, fork_repo, and the fork git remote are all absent.
Error flow
setup_workspace → creates workspace, clones repo, creates branch (no fork)
sets current_node = "implementation"
implement_bug_fix (= implement_task)
├─ prepare_workspace(state)
│ ├─ workspace exists on disk → pull_rebase("fork") → FAILS (no fork remote)
│ └─ fallback _recreate_workspace_from_fork() → FAILS (fork_owner/fork_repo empty)
│
└─ (if workspace survives) container runs successfully → push_to_fork_with_retry()
└─ git push -u fork <branch> → FAILS (no fork remote)
Affected paths
- Bug workflow:
plan_approval → decompose_plan → setup_workspace → implement_bug_fix
- Feature workflow:
task_approval → setup_workspace → implement_task
Any first-pass implementation where no PR has been created yet.
Post-PR paths are NOT affected
implement_review and attempt_ci_fix run after create_pull_request, so fork_owner/fork_repo are always populated.
Fix
Two changes needed in the first-pass path:
1. src/forge/workflow/nodes/workspace_setup.py — prepare_workspace()
When the workspace exists on disk but no fork info is available, skip the sync and return the existing workspace:
if workspace_path and Path(workspace_path).exists():
workspace = Workspace(...)
git = GitOperations(workspace)
if not fork_owner or not fork_repo:
return workspace_path, git
try:
git.pull_rebase(remote=remote)
...
2. src/forge/workflow/nodes/implementation.py — implement_task()
Guard both push_to_fork_with_retry() call sites so they only push when a fork exists:
has_fork = bool(state.get("fork_owner") and state.get("fork_repo"))
# "all tasks done" path
if has_fork:
await push_to_fork_with_retry(git)
# "per-task commit" path
if has_fork:
await push_to_fork_with_retry(git)
Reproduction
- Create a bug ticket with
forge:managed label
- Let Forge generate RCA and plan
- Approve the plan (set
forge:plan-approved)
- Worker reaches
implement_bug_fix → crashes with the fork error
Versions
Introduced in commit 7ebb8b7 (PR #168), present on current main.
Bug
implement_taskfails on the first implementation pass (before any PR is created) with two cascading errors:git fetch fork— "fatal: 'fork' does not appear to be a git repository"Cannot recreate workspace for <TICKET>: missing branch_name, current_repo, fork_owner, or fork_repo in stateIf the workspace survives and the fetch error is bypassed, a second failure occurs after the container completes successfully:
git push -u fork <branch>— "fatal: 'fork' does not appear to be a git repository"Root cause
Commit 7ebb8b7 ("fix: persist review handoffs across workers", PR #168) added
prepare_workspace()andpush_to_fork_with_retry()calls toimplement_task(). Both assume a fork remote already exists. On the first implementation pass the fork is not created untilcreate_pull_request, sofork_owner,fork_repo, and theforkgit remote are all absent.Error flow
Affected paths
plan_approval → decompose_plan → setup_workspace → implement_bug_fixtask_approval → setup_workspace → implement_taskAny first-pass implementation where no PR has been created yet.
Post-PR paths are NOT affected
implement_reviewandattempt_ci_fixrun aftercreate_pull_request, sofork_owner/fork_repoare always populated.Fix
Two changes needed in the first-pass path:
1.
src/forge/workflow/nodes/workspace_setup.py—prepare_workspace()When the workspace exists on disk but no fork info is available, skip the sync and return the existing workspace:
2.
src/forge/workflow/nodes/implementation.py—implement_task()Guard both
push_to_fork_with_retry()call sites so they only push when a fork exists:Reproduction
forge:managedlabelforge:plan-approved)implement_bug_fix→ crashes with the fork errorVersions
Introduced in commit 7ebb8b7 (PR #168), present on current
main.