{"record":{"id":"c86c66194a37a17e","repo":"gastownhall/beads","slug":"database-not-available-w","errorCode":null,"errorMessage":"database not available: %w","messagePattern":"database not available: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"cmd/bd/ado.go","lineNumber":517,"sourceCode":"\t\treturn err\n\t}\n\n\tif !adoSyncDryRun {\n\t\tCheckReadonly(\"ado sync\")\n\t}\n\n\tif adoSyncPullOnly && adoSyncPushOnly {\n\t\treturn fmt.Errorf(\"cannot use both --pull-only and --push-only\")\n\t}\n\n\t// Validate conflict flags\n\tconflictStrategy, err := getADOConflictStrategy(adoPreferLocal, adoPreferADO, adoPreferNewer)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"%w (--prefer-local, --prefer-ado, --prefer-newer)\", err)\n\t}\n\n\tif err := ensureStoreActive(); err != nil {\n\t\treturn fmt.Errorf(\"database not available: %w\", err)\n\t}\n\n\tout := cmd.OutOrStdout()\n\tctx := context.Background()\n\n\t// Create and initialize the ADO tracker\n\tat := &ado.Tracker{}\n\tcliProjects, _ := cmd.Flags().GetStringSlice(\"project\")\n\tif len(cliProjects) > 0 {\n\t\tat.SetProjects(tracker.DeduplicateStrings(cliProjects))\n\t}\n\tif err := at.Init(ctx, store); err != nil {\n\t\treturn fmt.Errorf(\"initializing Azure DevOps tracker: %w\", err)\n\t}\n\n\t// Build pull filters from CLI flags, falling back to config values.\n\tfilters := buildADOPullFilters(ctx, cmd)\n\tif filters != nil {","sourceCodeStart":499,"sourceCodeEnd":535,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/ado.go#L499-L535","documentation":"Wraps an error from ensureStoreActive() during `bd ado sync`, meaning the local beads issue store (Dolt-backed database) could not be opened/activated. Sync needs a live local store before the ADO tracker is initialized, so this check precedes all sync work and %w preserves the driver-level cause.","triggerScenarios":"ensureStoreActive fails: no database initialized in the current directory (`bd init` never run), .beads directory missing/corrupt, Dolt server unreachable in server mode, or wrong working directory.","commonSituations":"Running `bd ado sync` from the wrong repo/directory; a fresh clone without `bd init` or the migrated .beads data; the embedded/local Dolt DB locked or crashed; config pointing at a backend that isn't running.","solutions":["Run the command from the repository root that contains .beads/.","Initialize if needed: `bd init`, then retry the sync.","If in server mode, verify the Dolt server/database is up (and credentials in metadata/config are correct).","Read the wrapped cause after 'database not available:' for the driver-specific problem (missing dir vs. connection refused vs. corruption).","Restore from git backup if the .beads store is corrupt."],"exampleFix":"// before\n$ cd ~/proj-subdir && bd ado sync\nError: database not available: no beads database found\n\n// after\n$ cd ~/proj && bd ado sync","handlingStrategy":"validation","validationCode":"if _, err := os.Stat(filepath.Join(cwd, \".beads\")); err != nil {\n\treturn fmt.Errorf(\"run from repo root with an initialized beads store: %w\", err)\n}\n// then `bd init` if needed before `bd ado sync`","typeGuard":"func storeReady() bool {\n\t_, err := os.Stat(\".beads\")\n\treturn err == nil\n}","tryCatchPattern":"if err := bd(\"ado\", \"sync\"); err != nil {\n\tif strings.Contains(err.Error(), \"database not available\") {\n\t\t_ = bd(\"init\")\n\t\terr = bd(\"ado\", \"sync\")\n\t}\n\treturn err\n}","preventionTips":["Always run bd ado sync from the repository root.","Run bd init as part of repo bootstrap (alongside other setup scripts).","Keep .beads committed/backed up so clones are ready; monitor Dolt server health in server mode."],"tags":["database","dolt","storage","sync"],"backgroundTag":"database-unavailable","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}