gastownhall/beads · warning
worktree removal interrupted after target resolution: %w
Error message
worktree removal interrupted after target resolution: %w
What it means
This error reports that a caller-injected interruption hook (`afterTargetResolution`) returned an error while bd was building the worktree removal plan, after the target worktree had been resolved but before any mutation. bd wraps the hook's error so it is clear the abort happened at the 'after target resolution' checkpoint of the removal pipeline. It is a deliberate abort mechanism (used by tests/preview flows), not an internal fault.
Source
Thrown at cmd/bd/worktree_cmd.go:1258
return nil, err
}
plan := &worktreeRemovalPlan{
force: options.force.value,
prepareFacts: worktreeremove.PrepareFacts{
Registration: worktreeremove.Present,
},
}
if targetEntry.isMain {
plan.prepareFacts.Target = worktreeremove.PrimaryWorktree
return plan, nil
}
if sameWorktreePath(targetEntry.path, currentRoot) {
plan.prepareFacts.Target = worktreeremove.CurrentWorktree
return plan, nil
}
if afterTargetResolution != nil {
if err := afterTargetResolution(); err != nil {
return nil, fmt.Errorf("worktree removal interrupted after target resolution: %w", err)
}
}
mainCommonDirOutput, err := gitRunner.output(
ctx,
mainWorktree.path,
"rev-parse",
"--path-format=absolute",
"--git-common-dir",
)
if err != nil {
return nil, fmt.Errorf("failed to resolve repository common git directory: %w", err)
}
mainCommonDir := filepath.Clean(strings.TrimSpace(string(mainCommonDirOutput)))
target, err := inspectWorktreeTarget(ctx, gitRunner, targetEntry)
if err != nil {
return nil, errView on GitHub (pinned to 71377f2769)
Solutions
- Inspect the wrapped cause (%w) to see why the hook aborted; that cause is the real error
- Re-run the removal and accept the confirmation/hook when prompted
- If a test or script injects the abort, fix the hook to return nil when removal should proceed
Example fix
// before
afterTargetResolution: func() error { return errors.New("user cancelled") }
// after: proceed with removal
afterTargetResolution: nil // or return nil from the hook Defensive patterns
Strategy: try-catch
Validate before calling
null
Try / catch
plan, err := buildWorktreeRemovalPlan(ctx, git, name, afterHook)
var we *fmt.wrapError
if err != nil && errors.As(err, &we) {
return fmt.Errorf("removal aborted at afterTargetResolution: %v", we.Unwrap())
} Prevention
- Ensure afterTargetResolution hooks return nil when removal should proceed
- Treat this error as an expected abort path, not a bug
- Log the unwrapped cause for user-facing messaging
- Don't do mutating work inside the hook — keep it a pure decision point
When it happens
Trigger: Any worktree removal that passes an `afterTargetResolution` callback (testing hooks, preview/confirm flows) where the callback returns a non-nil error — e.g. a user answering 'no' at a confirmation prompt or a test injecting an abort.
Common situations: Interactive confirmation cancelled by the user; automated tests simulating a crash between target resolution and common-dir inspection; external tooling aborting the plan mid-way.
Related errors
- failed to inspect created worktree cleanliness: %w %s
- created worktree is dirty after checkout; refusing to contin
- worktree not found: %s
- failed to read git worktree registry: %w
- git worktree registry is empty
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/46b3433c51adc150.
Report an issue: GitHub.