{"record":{"id":"2113c5eb5bde12a9","repo":"gastownhall/beads","slug":"no-database-run-bd-init-or-bd-bootstrap-firs","errorCode":null,"errorMessage":"no database — run 'bd init' or 'bd bootstrap' first","messagePattern":"no database — run 'bd init' or 'bd bootstrap' first","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/import.go","lineNumber":229,"sourceCode":"\tUpdatedIssues       []ImportChange `json:\"updated_issues,omitempty\"`\n\tTieKeptLocalIDs     []string       `json:\"tie_kept_local_ids,omitempty\"`\n\tStaleSkippedIDs     []string       `json:\"stale_skipped_ids,omitempty\"`\n\tSkippedDependencies []string       `json:\"skipped_dependencies,omitempty\"`\n\tDryRun              bool           `json:\"dry_run,omitempty\"`\n}\n\nfunc runImportFromReader(ctx context.Context, r io.Reader, source string) error {\n\tissues, memories, err := parseImportRecords(r)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif usesProxiedServer() {\n\t\treturn runImportRecordsProxied(ctx, issues, memories, source)\n\t}\n\n\tif store == nil {\n\t\treturn fmt.Errorf(\"no database — run 'bd init' or 'bd bootstrap' first\")\n\t}\n\treturn runImportRecordsClassic(ctx, issues, memories, source)\n}\n\n// parseImportRecords scans one JSONL stream into issue rows and memory\n// records — the `bd import` / `bd import -` parse loop, shared by the classic\n// and proxied modes. Same record vocabulary as parseJSONLFile (the bootstrap\n// reader): the optional _schema header and tombstones are skipped, and the\n// \"wisp_plane\" boolean is honored as the explicit wisps-plane marker (and\n// the legacy \"wisp\" alias for \"ephemeral\") via applyImportWispPlane.\nfunc parseImportRecords(r io.Reader) ([]*types.Issue, []memoryRecord, error) {\n\tscanner := bufio.NewScanner(r)\n\tscanner.Buffer(make([]byte, 0, 1024*1024), 64*1024*1024)\n\n\tvar issues []*types.Issue\n\tvar memories []memoryRecord\n\n\tfor scanner.Scan() {","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/import.go#L211-L247","documentation":"bd import was invoked without an open database handle. In the classic (embedded) import path, the shared `store` is nil because no repository has been initialized, so the command aborts instead of writing into nothing. bd requires an explicit `bd init` (create empty DB) or `bd bootstrap` (init plus seed context) before any record operations.","triggerScenarios":"Running `bd import file.jsonl` (or `bd import -`) in a directory with no `.beads` database, or after `bd db --delete`/a failed init, so runImportFromReader reaches runImportRecordsClassic with store==nil.","commonSituations":"Cloning a repo whose .beads data was gitignored; running bd in the wrong working directory; a fresh CI container that skips the init step; corrupted or deleted beads database file.","solutions":["Run `bd init` in the project root to create the database, then re-run the import","Run `bd bootstrap` if you want init plus seeded project context","Verify you are in the intended directory (`pwd`) and that `.beads/` exists","In scripts/CI, add an init guard: `[ -d .beads ] || bd init` before importing"],"exampleFix":"// before (fresh checkout, CI script)\nbd import issues.jsonl   # error: no database\n// after\nbd init\nbd import issues.jsonl","handlingStrategy":"validation","validationCode":"if [ ! -d .beads ]; then bd init; fi\nbd import data.jsonl","typeGuard":null,"tryCatchPattern":"if ! bd import data.jsonl; then\n  bd init\n  bd import data.jsonl\nfi","preventionTips":["Always run bd init (or bd bootstrap) before scripted imports","Check for .beads/ directory existence in CI before any bd command","Pin the working directory in scripts so import never runs in the wrong repo","Add a bd doctor step to pipeline preflight checks"],"tags":["cli","database","initialization"],"backgroundTag":"database-not-initialized","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}