{"record":{"id":"a11382acd346396a","repo":"gastownhall/beads","slug":"failed-to-get-current-commit-w","errorCode":null,"errorMessage":"failed to get current commit: %w","messagePattern":"failed to get current commit: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/backup_export.go","lineNumber":142,"sourceCode":"\n// runBackupExport performs a Dolt-native backup to .beads/backup/.\n// Returns the updated state.\nfunc runBackupExport(ctx context.Context, force bool) (*backupState, error) {\n\tdir, err := backupDir()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tstate, err := loadBackupState(dir)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Change detection: skip if nothing changed (unless forced)\n\tif !force {\n\t\tcurrentCommit, err := store.GetCurrentCommit(ctx)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to get current commit: %w\", err)\n\t\t}\n\t\tif currentCommit == state.LastDoltCommit && state.LastDoltCommit != \"\" {\n\t\t\tdebug.Logf(\"backup: no changes since last backup (commit %s)\\n\", truncateHash(currentCommit))\n\t\t\treturn state, nil\n\t\t}\n\t}\n\n\tbs, ok := storage.UnwrapStore(store).(storage.BackupStore)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"storage backend does not support backup operations\")\n\t}\n\n\tif err := bs.BackupDatabase(ctx, dir); err != nil {\n\t\t// Persist the attempt time even on failure so the throttle\n\t\t// interval (checked by maybeAutoBackup via state.Timestamp)\n\t\t// applies to the next command. Without this, a sync that keeps\n\t\t// failing — e.g. a slow/overloaded shared Dolt server — retries\n\t\t// on EVERY bd command instead of once per interval, turning a","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/backup_export.go#L124-L160","documentation":"During change detection, runBackupExport asks the store for the current Dolt commit hash (store.GetCurrentCommit) to skip backups when nothing changed. This wraps any failure from that query — typically a storage-layer or database access error, not a git error.","triggerScenarios":"GetCurrentCommit(ctx) returns an error while running an auto-backup (maybeAutoBackup) or forced backup export: corrupted/locked Dolt database, missing dolt storage files, or a store whose backend lacks commit metadata.","commonSituations":"Interrupted Dolt operation leaving .beads/dolt in a bad state; concurrent bd processes locking the database; corrupted repository after disk issues; running against a non-Dolt storage backend that still advertises backup-adjacent behavior.","solutions":["Run `bd doctor` to diagnose database/storage health.","Check for concurrent bd processes holding locks and stop them.","If Dolt storage is corrupted, restore from .beads/backup/ or re-sync from remote: bd dolt pull.","Use `--force` semantics via explicit backup if change detection is blocking, and file an issue if GetCurrentCommit fails persistently on a healthy DB."],"exampleFix":"// shell\nbd doctor            # diagnose storage health\nbd dolt pull         # resync from remote if local Dolt state is corrupt","handlingStrategy":"try-catch","validationCode":"// probe storage health before backup-dependent flows\n// bd doctor   (or) verify Dolt store opens and commits are queryable\nif _, err := os.Stat(\".beads/dolt\"); err != nil {\n    log.Println(\"no Dolt storage present; change detection unavailable\")\n}","typeGuard":null,"tryCatchPattern":"state, err := runBackupExport(ctx, store, dir, false)\nif err != nil {\n    if strings.Contains(err.Error(), \"failed to get current commit\") {\n        log.Printf(\"Dolt commit lookup failed; run `bd doctor` / resync: %v\", err)\n        // fall back to forced backup or skip throttle cycle\n        state, err = runBackupExport(ctx, store, dir, true)\n    }\n    if err != nil { return err }\n}","preventionTips":["Run bd doctor periodically to catch Dolt corruption early","Avoid running multiple bd processes against the same workspace concurrently","Keep a known-good .beads/backup/ and remote sync (bd dolt push) so recovery is possible"],"tags":["go","dolt","database","backup"],"backgroundTag":"dolt-query-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}