{"record":{"id":"90636f11b4060474","repo":"gastownhall/beads","slug":"failed-to-set-sync-branch-w","errorCode":null,"errorMessage":"failed to set sync branch: %w","messagePattern":"failed to set sync branch: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/init_team.go","lineNumber":90,"sourceCode":"\t\tbranchName, err := readLineWithContext(ctx, reader, os.Stdin)\n\t\tif err != nil {\n\t\t\tif isCanceled(err) {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tbranchName = \"\"\n\t\t}\n\t\tbranchName = strings.TrimSpace(branchName)\n\n\t\tif branchName == \"\" {\n\t\t\tsyncBranch = \"beads-metadata\"\n\t\t} else {\n\t\t\tsyncBranch = branchName\n\t\t}\n\n\t\tfmt.Printf(\"\\n%s Sync branch set to: %s\\n\", ui.RenderPass(\"✓\"), syncBranch)\n\n\t\tif err := store.SetConfig(ctx, \"sync.branch\", syncBranch); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to set sync branch: %w\", err)\n\t\t}\n\n\t\t// Create the sync branch if it doesn't exist\n\t\tfmt.Printf(\"\\n%s Creating sync branch...\\n\", ui.RenderAccent(\"▶\"))\n\n\t\tif err := createSyncBranch(syncBranch); err != nil {\n\t\t\tfmt.Fprintf(os.Stderr, \"Warning: failed to create sync branch: %v\\n\", err)\n\t\t\tfmt.Println(\"  You can create it manually: git checkout -b\", syncBranch)\n\t\t} else {\n\t\t\tfmt.Printf(\"%s Sync branch created\\n\", ui.RenderPass(\"✓\"))\n\t\t}\n\n\t} else {\n\t\tfmt.Printf(\"%s Direct commits to %s\\n\", ui.RenderPass(\"✓\"), currentBranch)\n\t\tsyncBranch = currentBranch\n\t}\n\n\t// Step 3: Configure team settings","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/init_team.go#L72-L108","documentation":"runTeamWizard persists the chosen sync branch via store.SetConfig(ctx, \"sync.branch\", syncBranch). If the Dolt-backed storage layer fails to write that config key, the error is wrapped as 'failed to set sync branch: %w' and the wizard aborts. It signals a storage/config write failure, not a git problem.","triggerScenarios":"Calling runTeamWizard (via `bd init --team`) when the underlying Dolt store cannot execute the config upsert: database closed/unavailable, connection failure, schema/permission error, or read-only database.","commonSituations":"Dolt server not running or wrong connection settings; database directory not writable; corrupted local Dolt DB; store closed earlier in the command; disk full.","solutions":["Check the wrapped error to see the underlying storage failure (DB connectivity vs permissions)","Verify the Dolt database is reachable and started (`bd doctor` or dolt sql -q 'select 1')","Ensure the .beads/data directory and files are writable by the current user","Re-run `bd init` to repair/recreate the local database, then retry the team wizard"],"exampleFix":"// before\nif err := store.SetConfig(ctx, \"sync.branch\", syncBranch); err != nil {\n    return fmt.Errorf(\"failed to set sync branch: %w\", err)\n}\n// after (caller-side check before wizard)\nif err := store.SetConfig(ctx, \"sync.branch\", \"test-probe\"); err != nil {\n    fmt.Fprintln(os.Stderr, \"storage unavailable:\", err)\n    os.Exit(1)\n}","handlingStrategy":"try-catch","validationCode":"ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)\ndefer cancel()\nif err := store.Ping(ctx); err != nil { return fmt.Errorf(\"store unavailable: %w\", err) }","typeGuard":null,"tryCatchPattern":"if err := runTeamWizard(ctx, st); err != nil {\n    if strings.Contains(err.Error(), \"failed to set sync branch\") {\n        log.Printf(\"storage write failed: %v\", err) // inspect wrapped cause\n    }\n    return err\n}","preventionTips":["Confirm the Dolt database is reachable before the wizard","Ensure the .beads data directory is writable by the running user","Check disk space on the volume hosting the database"],"tags":["storage","config","dolt","init"],"backgroundTag":"config-write-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}