{"record":{"id":"794941db2d693dc8","repo":"gastownhall/beads","slug":"measure-active-database-directory-q-w-794941","errorCode":null,"errorMessage":"measure active database directory %q: %w","messagePattern":"measure active database directory %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/embeddeddolt/store.go","lineNumber":848,"sourceCode":"\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,\n// Commit itself tolerates Dolt's \"nothing to commit\" response (matching the\n// server store) and returns nil for it, so an error-based check here would\n// report every clean-store call as \"committed\", and a HEAD-before/HEAD-after\n// comparison would cost two extra engine opens on every call (this runs on","sourceCodeStart":830,"sourceCodeEnd":866,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/embeddeddolt/store.go#L830-L866","documentation":"EmbeddedDoltStore failed to compute the on-disk size of the active embedded Dolt database directory (s.CLIDir()). The wrapped error comes from storage.MeasureDirectorySize, so the underlying cause (missing directory, permission denial, context cancellation, filesystem error) is preserved. This store method implements the size/diagnostics surface of the storage interface and cannot report a size when the directory cannot be read or measured.","triggerScenarios":"Calling the store's size-measuring storage method (which routes to MeasureDirectorySize) when CLIDir() returns an empty path (that case has its own error), when the active database directory does not exist or was moved, when the process lacks read/search permission on the directory, or when the passed context is cancelled/timed out mid-walk.","commonSituations":"Running bd against an embedded Dolt database whose .beads data directory was deleted or relocated; running as a different user (e.g. via sudo/service account) without read access to the database dir; long-running size/diagnostic commands cancelled by context timeout on very large databases; WAL/working-tree inconsistencies leaving the CLIDir unset.","solutions":["Inspect the wrapped cause (%w) to determine whether it is a filesystem permission, missing-directory, or context error and fix that root cause first.","Verify the active database directory exists: run `ls` on the path printed in the error and confirm it contains the embedded Dolt database.","Fix permissions so the process user can read/traverse the directory (e.g. chown/chmod the .beads database directory).","If the directory is gone or corrupted, restore it (bd recovery/export flow) or re-initialize the embedded store before measuring again.","Avoid cancelling the command; on very large databases give the size operation more time or a longer context deadline."],"exampleFix":"// before: measuring without ensuring the dir is usable\nsize, err := store.MeasureSize(ctx)\n\n// after: pre-check directory access before calling\ndir := store.ActiveDir()\nif _, statErr := os.Stat(dir); statErr != nil {\n    return fmt.Errorf(\"active db dir %q unavailable: %w\", dir, statErr)\n}\nctx, cancel := context.WithTimeout(ctx, 30*time.Second)\ndefer cancel()\nsize, err := store.MeasureSize(ctx)","handlingStrategy":"validation","validationCode":"dir := store.ActiveDir() // or however CLIDir is exposed\nif dir == \"\" {\n    return errors.New(\"embedded store has no active database directory\")\n}\nif fi, err := os.Stat(dir); err != nil || !fi.IsDir() {\n    return fmt.Errorf(\"active db dir %q unavailable: %w\", dir, err)\n}\nif err := ctx.Err(); err != nil {\n    return err\n}","typeGuard":null,"tryCatchPattern":"var sizeErr *fs.PathError\nif err := measure(ctx); err != nil {\n    if errors.As(err, &sizeErr) {\n        // permission / missing dir on the db directory\n    }\n    if errors.Is(err, context.DeadlineExceeded) {\n        // retry with longer budget\n    }\n    return err\n}","preventionTips":["Never move or delete the .beads embedded database directory while bd commands may run.","Run bd as a user with read access to the database directory (watch sudo/service-account setups).","Set generous context timeouts for size/diagnostic operations on large databases.","Verify store initialization succeeded before calling size/diagnostic methods."],"tags":["embeddeddolt","storage","filesystem","diagnostics"],"backgroundTag":"database-directory-unreadable","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}