{"record":{"id":"06aeb4da5b61d64f","repo":"gastownhall/beads","slug":"embeddeddolt-active-database-directory-is-empty","errorCode":null,"errorMessage":"embeddeddolt: active database directory is empty","messagePattern":"embeddeddolt: active database directory is empty","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/embeddeddolt/store.go","lineNumber":844,"sourceCode":"// CLIDir returns the directory for dolt CLI operations (push/pull/remote).\n// This is the actual database directory within the data dir.\nfunc (s *EmbeddedDoltStore) CLIDir() string {\n\tif s.dataDir == \"\" {\n\t\treturn \"\"\n\t}\n\treturn filepath.Join(s.dataDir, s.database)\n}\n\n// ActiveDatabaseSize returns the approximate size of this store's active\n// database directory. Sibling databases under the embedded data root are not\n// part of the result.\nfunc (s *EmbeddedDoltStore) ActiveDatabaseSize(ctx context.Context) (int64, error) {\n\tif s.closed.Load() {\n\t\treturn 0, errClosed\n\t}\n\tactiveDir := s.CLIDir()\n\tif activeDir == \"\" {\n\t\treturn 0, fmt.Errorf(\"embeddeddolt: active database directory is empty\")\n\t}\n\tsize, err := storage.MeasureDirectorySize(ctx, activeDir)\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"measure active database directory %q: %w\", activeDir, err)\n\t}\n\treturn size, nil\n}\n\n// ---------------------------------------------------------------------------\n// storage.VersionControl\n// ---------------------------------------------------------------------------\n\n// Branch, Checkout, CurrentBranch, DeleteBranch, ListBranches are\n// implemented in version_control.go via versioncontrolops.\n\n// CommitPending commits all working set changes and reports whether a commit\n// actually landed. It gets that from commitAll's returned bool rather than\n// inspecting Commit's error or reading HEAD before and after: as of GH#3886,","sourceCodeStart":826,"sourceCodeEnd":862,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/embeddeddolt/store.go#L826-L862","documentation":"ActiveDatabaseSize reports the on-disk size of the active embedded database by measuring s.CLIDir(); this error is returned when CLIDir() yields an empty string, meaning the store has no resolvable active database directory (misconfigured or not yet initialized store). Note the store's closed flag is checked first (errClosed), so this specifically indicates an open store whose CLI directory is empty. Measurement never even starts in this case.","triggerScenarios":"Calling ActiveDatabaseSize on an EmbeddedDoltStore constructed without a data directory / CLI dir configuration such that CLIDir() returns \"\" — e.g. a zero-value or partially configured store, or a store whose dataDir resolution failed silently; typically only via direct library use or unusual configuration rather than normal bd operation.","commonSituations":"Programmatic use constructing EmbeddedDoltStore without setting DataDir; tests or tooling instantiating the store directly instead of via newStore; monitoring scripts calling size reporting on a misconfigured store.","solutions":["Construct the store through newStore with a valid DataDir rather than direct struct instantiation.","Verify the configured data directory (.beads metadata / config) points at an existing Dolt database directory.","Run 'bd doctor' to confirm the store configuration resolves to a real database directory.","If writing library code, treat an empty CLIDir as uninitialized and initialize before querying size."],"exampleFix":"// before\nstore := &EmbeddedDoltStore{} // CLIDir() == \"\"\nsize, err := store.ActiveDatabaseSize(ctx)\n\n// after\nstore, err := newStore(ctx, EmbeddedDoltConfig{DataDir: \"/repo/.beads/dolt\"})\nsize, err := store.ActiveDatabaseSize(ctx)","handlingStrategy":"validation","validationCode":"dir := store.CLIDir()\nif dir == \"\" {\n    return fmt.Errorf(\"store not configured with a data directory\")\n}\nif _, err := os.Stat(dir); err != nil {\n    return fmt.Errorf(\"database dir %q missing: %w\", dir, err)\n}","typeGuard":null,"tryCatchPattern":"size, err := store.ActiveDatabaseSize(ctx)\nif err != nil && strings.Contains(err.Error(), \"active database directory is empty\") {\n    // rebuild store via newStore with a valid DataDir, then retry\n    return fmt.Errorf(\"store uninitialized: %w\", err)\n}","preventionTips":["Always construct stores via newStore with a non-empty DataDir","Never instantiate EmbeddedDoltStore directly in application code","Verify .beads metadata resolves to a real database directory before size reporting","Guard monitoring code to skip stores without a configured directory"],"tags":["embedded-dolt","configuration","storage-size"],"backgroundTag":"missing-data-dir","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}