{"record":{"id":"2987edb8c9a9560b","repo":"gastownhall/beads","slug":"no-database-configuration-found","errorCode":null,"errorMessage":"no database configuration found","messagePattern":"no database configuration found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"cmd/bd/doctor/fix/validation.go","lineNumber":327,"sourceCode":"\t}\n\tdefer db.Close()\n\n\tvar count int\n\tif err := db.QueryRow(`SELECT COUNT(*) FROM issues WHERE id IN (SELECT id FROM wisps)`).Scan(&count); err != nil {\n\t\treturn 0, fmt.Errorf(\"query cross-table duplicates: %w\", err)\n\t}\n\treturn count, nil\n}\n\n// openDoltDB opens a Dolt database connection via MySQL protocol.\n// Delegates to openFixDB for DSN construction (timeout + password support).\n// Also returns the loaded config so callers that need it afterward (e.g. to\n// verify the connection's target identity) don't have to load it a second\n// time and risk it disagreeing with what was actually dialed.\nfunc openDoltDB(beadsDir string) (*sql.DB, *configfile.Config, error) {\n\tcfg, err := configfile.Load(beadsDir)\n\tif err != nil || cfg == nil {\n\t\treturn nil, nil, fmt.Errorf(\"no database configuration found\")\n\t}\n\n\tdb, err := openFixDB(beadsDir, cfg)\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"dolt server connection failed: %w\", err)\n\t}\n\n\t// Verify the connection actually works\n\tif err := db.Ping(); err != nil {\n\t\t_ = db.Close() // Best effort cleanup\n\t\treturn nil, nil, fmt.Errorf(\"dolt server not reachable: %w\", err)\n\t}\n\n\treturn db, cfg, nil\n}\n","sourceCodeStart":309,"sourceCodeEnd":343,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/doctor/fix/validation.go#L309-L343","documentation":"openDoltDB is the shared connection helper for doctor fix routines. It first loads the database config via configfile.Load(beadsDir); if loading errors or returns nil (no config file present), it returns the sentinel error \"no database configuration found\". This is not a connection failure — beads cannot even determine which Dolt server/database to dial.","triggerScenarios":"configfile.Load(beadsDir) returns an error (malformed/unreadable config JSON) or nil config (.beads/config.json absent) while any fix routine (OrphanedDependencies, RecomputeBlocked, DependencyKeys, etc.) tries to open the DB.","commonSituations":"Running `bd doctor --fix` outside an initialized beads workspace (no .beads directory); config.json deleted or corrupted; wrong --path/beadsDir pointing at a directory that isn't a beads root; permissions blocking the config read.","solutions":["Initialize the workspace: run `bd init` (or `bd doctor`) so .beads/config.json is created","Point the command at the correct repo/beads directory (check the path argument)","Inspect .beads/config.json for corruption or bad JSON and repair or regenerate it","Check file permissions on .beads/ so the process can read the config"],"exampleFix":"// before: running fix in a directory with no beads config\n$ cd /tmp && bd doctor --fix\n  Orphaned dependencies fix skipped (no database configuration found)\n// after: run from the repo root with an initialized .beads\n$ cd ~/my-repo && bd init && bd doctor --fix","handlingStrategy":"validation","validationCode":"// Check config presence before calling fix routines that open the DB\nbeadsDir := filepath.Join(repoRoot, \".beads\")\nif _, err := os.Stat(filepath.Join(beadsDir, \"config.json\")); err != nil {\n    return fmt.Errorf(\"not a beads workspace: run 'bd init' in %s\", repoRoot)\n}","typeGuard":null,"tryCatchPattern":"db, cfg, err := openDoltDB(beadsDir)\nif err != nil {\n    if strings.Contains(err.Error(), \"no database configuration found\") {\n        // not an initialized workspace: skip fix, don't crash\n        fmt.Println(\"fix skipped: run 'bd init' first\")\n        return nil\n    }\n    return err\n}","preventionTips":["Run doctor fixes from the repo root (or pass the correct beads dir)","Run `bd init` before any fix subcommands in a fresh clone","Keep .beads/config.json under version control or backed up","Check file permissions if config.json exists but can't be read"],"tags":["config","database","beads","initialization"],"backgroundTag":"missing-config-file","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}