gastownhall/beads · error

failed to get current commit: %w

Error message

failed to get current commit: %w

What it means

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.

Source

Thrown at cmd/bd/backup_export.go:142

// runBackupExport performs a Dolt-native backup to .beads/backup/.
// Returns the updated state.
func runBackupExport(ctx context.Context, force bool) (*backupState, error) {
	dir, err := backupDir()
	if err != nil {
		return nil, err
	}

	state, err := loadBackupState(dir)
	if err != nil {
		return nil, err
	}

	// Change detection: skip if nothing changed (unless forced)
	if !force {
		currentCommit, err := store.GetCurrentCommit(ctx)
		if err != nil {
			return nil, fmt.Errorf("failed to get current commit: %w", err)
		}
		if currentCommit == state.LastDoltCommit && state.LastDoltCommit != "" {
			debug.Logf("backup: no changes since last backup (commit %s)\n", truncateHash(currentCommit))
			return state, nil
		}
	}

	bs, ok := storage.UnwrapStore(store).(storage.BackupStore)
	if !ok {
		return nil, fmt.Errorf("storage backend does not support backup operations")
	}

	if err := bs.BackupDatabase(ctx, dir); err != nil {
		// Persist the attempt time even on failure so the throttle
		// interval (checked by maybeAutoBackup via state.Timestamp)
		// applies to the next command. Without this, a sync that keeps
		// failing — e.g. a slow/overloaded shared Dolt server — retries
		// on EVERY bd command instead of once per interval, turning a

View on GitHub (pinned to 71377f2769)

Solutions

  1. Run `bd doctor` to diagnose database/storage health.
  2. Check for concurrent bd processes holding locks and stop them.
  3. If Dolt storage is corrupted, restore from .beads/backup/ or re-sync from remote: bd dolt pull.
  4. Use `--force` semantics via explicit backup if change detection is blocking, and file an issue if GetCurrentCommit fails persistently on a healthy DB.

Example fix

// shell
bd doctor            # diagnose storage health
bd dolt pull         # resync from remote if local Dolt state is corrupt
Defensive patterns

Strategy: try-catch

Validate before calling

// probe storage health before backup-dependent flows
// bd doctor   (or) verify Dolt store opens and commits are queryable
if _, err := os.Stat(".beads/dolt"); err != nil {
    log.Println("no Dolt storage present; change detection unavailable")
}

Try / catch

state, err := runBackupExport(ctx, store, dir, false)
if err != nil {
    if strings.Contains(err.Error(), "failed to get current commit") {
        log.Printf("Dolt commit lookup failed; run `bd doctor` / resync: %v", err)
        // fall back to forced backup or skip throttle cycle
        state, err = runBackupExport(ctx, store, dir, true)
    }
    if err != nil { return err }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30). Data as JSON: /api/errors/a11382acd346396a. Report an issue: GitHub.