{"record":{"id":"f1086293547847ec","repo":"gastownhall/beads","slug":"failed-to-load-config-w","errorCode":null,"errorMessage":"failed to load config: %w","messagePattern":"failed to load config: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/doctor/dolt.go","lineNumber":24,"sourceCode":"\t\"fmt\"\n\t\"strings\"\n\t\"time\"\n\n\t// MySQL driver for connecting to dolt sql-server\n\t_ \"github.com/go-sql-driver/mysql\"\n\n\t\"github.com/steveyegge/beads/internal/configfile\"\n\t\"github.com/steveyegge/beads/internal/doltserver\"\n\n\t\"github.com/steveyegge/beads/internal/storage/dolt\"\n\t\"github.com/steveyegge/beads/internal/storage/doltutil\"\n)\n\n// openDoltDB opens a connection to the Dolt SQL server via MySQL protocol.\nfunc openDoltDB(beadsDir string) (*sql.DB, *configfile.Config, error) {\n\tcfg, err := configfile.Load(beadsDir)\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"failed to load config: %w\", err)\n\t}\n\tif cfg == nil {\n\t\treturn nil, nil, fmt.Errorf(\"no beads configuration found in %s\", beadsDir)\n\t}\n\n\thost := cfg.GetDoltServerHost()\n\tuser := cfg.GetDoltServerUser()\n\tdatabase := cfg.GetDoltDatabase()\n\n\t// Use doltserver.DefaultConfig for port resolution (env > port file > config.yaml).\n\t// Port 0 means no server running yet.\n\tdsCfg := doltserver.DefaultConfig(beadsDir)\n\tport := dsCfg.Port\n\tif port == 0 {\n\t\treturn nil, nil, fmt.Errorf(\"no Dolt server port configured and no server running; run any bd command to auto-start\")\n\t}\n\n\t// Resolve the password using the credentials file fallback keyed by the","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/doctor/dolt.go#L6-L42","documentation":"openDoltDB loads the beads configuration file from the .beads directory before connecting to the Dolt SQL server. If configfile.Load fails (unreadable or malformed config), the error is wrapped here and propagates to openDoltConn/querySQLRemotes used by doctor's Dolt checks.","triggerScenarios":"openDoltDB (via openDoltConn/querySQLRemotes in `bd doctor` Dolt diagnostics) when configfile.Load(beadsDir) returns an error — missing/unreadable config.json in .beads, or JSON parse failure — at cmd/bd/doctor/dolt.go:24.","commonSituations":"Running bd doctor outside a beads-initialized directory or in the wrong one; .beads/config.json corrupted by a partial write or hand edit; restrictive file permissions; running as a different user than the one who initialized beads.","solutions":["Run bd from (or point it at) a directory initialized with `bd init` so .beads/config.json exists","Check ~/.beads or project .beads/config.json: verify it's readable and valid JSON (jq . config.json)","Fix permissions: chown/chmod .beads/config.json to your user","Restore a corrupt config (git checkout .beads/config.json or re-run bd init) and re-run bd doctor"],"exampleFix":"# before\n$ ls .beads/        # empty or missing config.json\n# after\n$ bd init\n$ ls .beads/config.json && jq . .beads/config.json","handlingStrategy":"validation","validationCode":"import \"os\", \"encoding/json\"\nfunc beadsConfigExists(beadsDir string) error {\n\tp := filepath.Join(beadsDir, \"config.json\")\n\tdata, err := os.ReadFile(p)\n\tif err != nil { return fmt.Errorf(\"%s: %w\", p, err) }\n\tvar v map[string]any\n\tif err := json.Unmarshal(data, &v); err != nil {\n\t\treturn fmt.Errorf(\"%s invalid JSON: %w\", p, err)\n\t}\n\treturn nil\n}","typeGuard":null,"tryCatchPattern":"db, cfg, err := openDoltDB(beadsDir)\nif err != nil {\n\tif strings.Contains(err.Error(), \"failed to load config\") {\n\t\tlog.Printf(\"run `bd init` in this directory or fix .beads/config.json: %v\", err)\n\t\treturn errSkipDoltChecks\n\t}\n\treturn err\n}","preventionTips":["Always initialize with `bd init` before running doctor Dolt checks","Validate .beads/config.json with jq after manual edits","Restore config from git after corruption instead of hand-repairing","Run bd as the same user that owns the .beads directory to avoid permission issues"],"tags":["config","dolt","doctor","database"],"backgroundTag":"config-load-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}