{"record":{"id":"89560712250ec2a5","repo":"gastownhall/beads","slug":"database-not-available-w-895607","errorCode":null,"errorMessage":"database not available: %w","messagePattern":"database not available: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/linear.go","lineNumber":1004,"sourceCode":"\t}\n\tif dbPath != \"\" {\n\t\treturn resolveCommandBeadsDir(dbPath)\n\t}\n\treturn \"\"\n}\n\n// uuidRegex matches valid UUID format (with or without hyphens).\nvar uuidRegex = regexp.MustCompile(`^[0-9a-fA-F]{8}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{12}$`)\n\nfunc isValidUUID(s string) bool {\n\treturn uuidRegex.MatchString(s)\n}\n\n// validateLinearConfig checks that required Linear configuration is present.\n// cliTeams is the list of team IDs from the --team flag (may be nil).\nfunc validateLinearConfig(cliTeams []string) error {\n\tif err := ensureStoreActive(); err != nil {\n\t\treturn fmt.Errorf(\"database not available: %w\", err)\n\t}\n\n\tctx := rootCtx\n\n\t// Accept either OAuth credentials or API key.\n\toauthClientID, _ := getLinearConfig(ctx, \"linear.oauth_client_id\")\n\toauthClientSecret, _ := getLinearConfig(ctx, \"linear.oauth_client_secret\")\n\thasOAuth := oauthClientID != \"\" && oauthClientSecret != \"\"\n\n\tif !hasOAuth {\n\t\tapiKey, _ := getLinearConfig(ctx, \"linear.api_key\")\n\t\tif apiKey == \"\" {\n\t\t\treturn fmt.Errorf(\"Linear authentication not configured\\n\" +\n\t\t\t\t\"Options:\\n\" +\n\t\t\t\t\"  OAuth (for CI):  export LINEAR_OAUTH_CLIENT_ID=... LINEAR_OAUTH_CLIENT_SECRET=...\\n\" +\n\t\t\t\t\"  API key (devs):  export LINEAR_API_KEY=... or bd config set linear.api_key \\\"YOUR_API_KEY\\\"\")\n\t\t}\n\t}","sourceCodeStart":986,"sourceCodeEnd":1022,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/linear.go#L986-L1022","documentation":"validateLinearConfig begins by calling ensureStoreActive(); every Linear sync/push/pull command requires an active bd database (Dolt-backed store). If no database is available or active, the underlying error is wrapped as 'database not available'.","triggerScenarios":"Running bd linear sync/push/pull outside a bd-initialized directory, with BD_DAEMON/daemon store not connected, or when the embedded/Dolt store failed to open.","commonSituations":"Running the command in a repo without `bd init`; the bd daemon is not running or crashed; the Dolt database directory is missing or corrupted; wrong working directory.","solutions":["Run `bd init` in the repository (or cd into the bd-initialized repo) before running linear commands","Check/start the bd daemon (`bd doctor`, restart `bd daemon`)","Verify the .beads/Dolt database files exist and are not corrupted; restore from backup if needed"],"exampleFix":"// before\n$ cd ~/somewhere && bd linear pull\nError: database not available: ...\n// after\n$ cd ~/myproject && bd init && bd linear pull","handlingStrategy":"validation","validationCode":"if _, err := os.Stat(\".beads\"); err != nil {\n\treturn fmt.Errorf(\"run 'bd init' first: %w\", err)\n}\nif err := exec.Command(\"bd\", \"doctor\").Run(); err != nil {\n\treturn fmt.Errorf(\"bd store unhealthy\")\n}","typeGuard":null,"tryCatchPattern":"err := validateLinearConfig(cliTeams)\nif err != nil && strings.Contains(err.Error(), \"database not available\") {\n\t// prompt/run: bd init, restart daemon, then retry\n}","preventionTips":["Always run bd commands inside a bd-initialized repository","Keep the bd daemon healthy and monitored in CI","Back up the Dolt database and verify with bd doctor"],"tags":["database","configuration","linear","store"],"backgroundTag":"database-not-available","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}