{"record":{"id":"671be11597366c00","repo":"gastownhall/beads","slug":"no-database-connection","errorCode":null,"errorMessage":"no database connection","messagePattern":"no database connection","errorType":"console","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"cmd/bd/cook.go","lineNumber":849,"sourceCode":"\tif vars != nil {\n\t\tsubgraph.VarDefs = make(map[string]formula.VarDef)\n\t\tfor k, v := range vars {\n\t\t\tif v != nil {\n\t\t\t\tsubgraph.VarDefs[k] = *v\n\t\t\t}\n\t\t}\n\t}\n\t// Attach recommended phase and pour flag from formula\n\tsubgraph.Phase = f.Phase\n\tsubgraph.Pour = f.Pour\n\treturn subgraph, nil\n}\n\n// cookFormula creates a proto bead from a resolved formula.\n// protoID is the final ID for the proto (may include a prefix).\nfunc cookFormula(ctx context.Context, s storage.DoltStorage, f *formula.Formula, protoID string) (*cookFormulaResult, error) {\n\tif s == nil {\n\t\treturn nil, fmt.Errorf(\"no database connection\")\n\t}\n\n\t// Map step ID -> created issue ID\n\tidMapping := make(map[string]string)\n\n\t// Collect all issues and dependencies\n\tvar issues []*types.Issue\n\tvar deps []*types.Dependency\n\tvar labels []struct{ issueID, label string }\n\n\t// Determine root title: use {{title}} placeholder if the variable is defined,\n\t// otherwise fall back to formula name (GH#852)\n\trootTitle := f.Formula\n\tif _, hasTitle := f.Vars[\"title\"]; hasTitle {\n\t\trootTitle = \"{{title}}\"\n\t}\n\n\t// Determine root description: use {{desc}} placeholder if the variable is defined,","sourceCodeStart":831,"sourceCodeEnd":867,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/cook.go#L831-L867","documentation":"Guard in cookFormula: it requires a non-nil storage.DoltStorage because cooking persists a proto bead and its dependencies to the Dolt database. A nil storage means the command has no open database connection, so cooking cannot proceed.","triggerScenarios":"cookFormula called (via persistCookFormula) with s == nil — i.e. the command ran without an initialized/open Dolt database handle, such as when persistence is requested but the store was never opened or was closed.","commonSituations":"Running `bd cook --persist` outside an initialized bd repository (no .beads database); database open failed earlier but the nil handle was passed through; daemon/server mode where the proxied server has no DB configured.","solutions":["Run `bd init` in the repository (or ensure .beads database exists) before cooking with persistence","Open the database before calling cook/persist (bd normally does this; check for earlier swallowed open errors)","Run the command from the repository root so the bd database is discovered","If embedding bd programmatically, pass a valid storage.DoltStorage instead of nil"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Before requesting persistent cook, ensure the store is open\nif store == nil {\n    return fmt.Errorf(\"cannot cook --persist: no database; run 'bd init' first\")\n}\nif _, err := os.Stat(filepath.Join(cwd, \".beads\")); err != nil {\n    return fmt.Errorf(\"not in a bd repository: %w\", err)\n}","typeGuard":"func hasStore(s storage.DoltStorage) bool { return s != nil }","tryCatchPattern":"result, err := cookFormula(ctx, store, f, protoID)\nif err != nil && err.Error() == \"no database connection\" {\n    // open the database (bd init / store open) then retry once\n    store, err = openStore(ctx)\n    if err == nil { result, err = cookFormula(ctx, store, f, protoID) }\n}","preventionTips":["Run bd commands from a repository containing an initialized .beads database","Run `bd init` before the first cook --persist","Check for earlier database-open errors instead of passing a nil store onward","In embedded usage, assert the DoltStorage handle is non-nil before invoking cook APIs"],"tags":["database","storage","initialization"],"backgroundTag":"missing-database-connection","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}