{"record":{"id":"8d3d55b98ef3cee3","repo":"gastownhall/beads","slug":"failed-to-set-routing-contributor-w","errorCode":null,"errorMessage":"failed to set routing.contributor: %w","messagePattern":"failed to set routing\\.contributor: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/init_contributor.go","lineNumber":339,"sourceCode":"\t\t}\n\t\tplanningBeadsDir := filepath.Join(planningPath, \".beads\")\n\t\tif err := os.MkdirAll(planningBeadsDir, 0750); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to create .beads in planning repo: %w\", err)\n\t\t}\n\t\t// Initialize the planning Dolt schema so commands like bd migrate-personal\n\t\t// can open the store immediately without hitting an uninitialized DB.\n\t\t// Non-fatal: no-CGO and server-mode builds skip this silently; the schema\n\t\t// initializes on first use once a Dolt server is running for that path.\n\t\tif planningStore, storeErr := newDoltStoreFromConfig(ctx, planningBeadsDir); storeErr == nil {\n\t\t\t_ = planningStore.Close()\n\t\t}\n\t}\n\n\tif err := store.SetConfig(ctx, \"routing.mode\", \"auto\"); err != nil {\n\t\treturn fmt.Errorf(\"failed to set routing.mode: %w\", err)\n\t}\n\tif err := store.SetConfig(ctx, \"routing.contributor\", planningPath); err != nil {\n\t\treturn fmt.Errorf(\"failed to set routing.contributor: %w\", err)\n\t}\n\tif err := store.SetConfig(ctx, \"sync.remote\", \"upstream\"); err != nil {\n\t\treturn fmt.Errorf(\"failed to set sync.remote: %w\", err)\n\t}\n\n\t_ = exec.Command(\"git\", \"config\", \"beads.role\", \"contributor\").Run()\n\n\tif configPath, err := config.FindConfigYAMLPath(); err == nil {\n\t\tif addErr := config.AddRepo(configPath, planningPath); addErr != nil && !strings.Contains(addErr.Error(), \"already exists\") {\n\t\t\t// Non-fatal: hydration config failure doesn't block routing setup\n\t\t}\n\t}\n\n\tif !quiet {\n\t\tfmt.Printf(\"\\n%s Fork detected — configuring contributor routing\\n\", ui.RenderAccent(\"▶\"))\n\t\tfmt.Printf(\"  upstream: %s\\n\\n\", upstreamURL)\n\t\tfmt.Printf(\"  %s Planning repo: %s\\n\", ui.RenderPass(\"✓\"), planningPath)\n\t\tfmt.Printf(\"  %s Issues will route to planning repo (routing.mode=auto)\\n\", ui.RenderPass(\"✓\"))","sourceCodeStart":321,"sourceCodeEnd":357,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/init_contributor.go#L321-L357","documentation":"During `bd init --contributor`, autoConfigureForkContributor persists fork-routing configuration keys via store.SetConfig. When writing the `routing.contributor` key (the planning-repo path) fails, the underlying store error is wrapped with this message. It means the fork-contributor auto-configuration aborted partway, after `routing.mode` was already set to `auto`.","triggerScenarios":"The store.SetConfig(ctx, \"routing.contributor\", planningPath) call returns an error — typically a locked or unwritable underlying database/config storage, a failed Dolt transaction, or a corrupted .beads config store during `bd init --contributor`.","commonSituations":"Running `bd init --contributor` in a repo whose .beads database is locked by another bd process, disk-full or permission-denied on the config storage, or a partially-corrupted config table left by a previous failed init.","solutions":["Ensure no other bd process holds the .beads database (close other sessions, remove stale locks) and re-run `bd init --contributor`.","Check filesystem permissions and free space on the directory containing the .beads store.","Read the wrapped underlying error after the colon — it identifies the exact storage failure.","If `routing.mode` was already set to `auto` but `routing.contributor` is missing, reset routing.mode and re-run init: `bd config set routing.mode local` (or equivalent) then `bd init --contributor`."],"exampleFix":"// before (partially configured repo)\nbd config get routing.contributor  // empty, routing.mode = auto\n// after: clear partial state and re-init\nbd config set routing.mode auto  // re-run full init\nbd init --contributor","handlingStrategy":"try-catch","validationCode":"// Check config store is writable before init\nif _, err := os.Stat(\".beads\"); err != nil { /* no beads dir; init will create it */ }\nif info, err := os.Stat(\".beads\"); err == nil && info.Mode()&0200 == 0 {\n    return fmt.Errorf(\".beads is not writable\")\n}","typeGuard":null,"tryCatchPattern":"if err := autoConfigureForkContributor(ctx, store, planningPath); err != nil {\n    if strings.Contains(err.Error(), \"failed to set routing.contributor\") {\n        // inspect wrapped cause, clear partial routing.mode, retry after fixing storage\n    }\n    return err\n}","preventionTips":["Avoid running multiple bd processes against the same .beads database concurrently.","Check disk space and .beads permissions before `bd init --contributor`.","Read the wrapped cause (%w) rather than just the message.","After a failed init, verify routing.mode/routing.contributor/sync.remote are consistent."],"tags":["config","init","storage"],"backgroundTag":"config-write-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}