From b420018b97b3b5afa4b9017c8e345a75f75d92d6 Mon Sep 17 00:00:00 2001 From: beads/crew/giles Date: Sat, 10 Jan 2026 23:42:49 -0800 Subject: [PATCH] fix: validate sync.branch in team wizard and migrate commands (GH#923) Two code paths bypassed syncbranch.ValidateSyncBranchName(), allowing main/master to be set as sync.branch and causing worktree conflicts. Now both use syncbranch.Set() for proper validation. Co-Authored-By: Claude Opus 4.5 --- cmd/bd/init_team.go | 5 +++-- cmd/bd/migrate.go | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cmd/bd/init_team.go b/cmd/bd/init_team.go index b5092c8e..1232611c 100644 --- a/cmd/bd/init_team.go +++ b/cmd/bd/init_team.go @@ -10,6 +10,7 @@ import ( "github.com/steveyegge/beads/internal/config" "github.com/steveyegge/beads/internal/storage" + "github.com/steveyegge/beads/internal/syncbranch" "github.com/steveyegge/beads/internal/ui" ) @@ -71,8 +72,8 @@ func runTeamWizard(ctx context.Context, store storage.Storage) error { fmt.Printf("\n%s Sync branch set to: %s\n", ui.RenderPass("✓"), syncBranch) - // Set sync.branch config - if err := store.SetConfig(ctx, "sync.branch", syncBranch); err != nil { + // Set sync.branch config (GH#923: use syncbranch.Set for validation) + if err := syncbranch.Set(ctx, store, syncBranch); err != nil { return fmt.Errorf("failed to set sync branch: %w", err) } diff --git a/cmd/bd/migrate.go b/cmd/bd/migrate.go index 90f233fd..927d2c25 100644 --- a/cmd/bd/migrate.go +++ b/cmd/bd/migrate.go @@ -12,6 +12,7 @@ import ( "github.com/steveyegge/beads/internal/beads" "github.com/steveyegge/beads/internal/configfile" "github.com/steveyegge/beads/internal/storage/sqlite" + "github.com/steveyegge/beads/internal/syncbranch" "github.com/steveyegge/beads/internal/types" "github.com/steveyegge/beads/internal/ui" "github.com/steveyegge/beads/internal/utils" @@ -933,8 +934,8 @@ func handleToSeparateBranch(branch string, dryRun bool) { return } - // Update sync.branch config - if err := store.SetConfig(ctx, "sync.branch", b); err != nil { + // Update sync.branch config (GH#923: use syncbranch.Set for validation) + if err := syncbranch.Set(ctx, store, b); err != nil { if jsonOutput { outputJSON(map[string]interface{}{ "error": "config_update_failed",