gastownhall/beads · error

db: %s: %w

Error message

db: %s: %w

What it means

Generic wrapper for failures executing a Dolt stored procedure via CALL. The %s is the procedure name (e.g. dolt_checkout, dolt_add, dolt_commit, dolt_merge), and the wrapped error is the raw SQL driver error. This centralizes all stored-procedure invocation errors from the dolt.go helper.

Source

Thrown at internal/storage/domain/db/dolt.go:88

func (i *doltVersionControlSQLRepository) Pull(ctx context.Context, args ...string) error {
	return i.call(ctx, "DOLT_PULL", args...)
}

func (i *doltVersionControlSQLRepository) Clone(ctx context.Context, args ...string) error {
	return i.call(ctx, "DOLT_CLONE", args...)
}

func (i *doltVersionControlSQLRepository) call(ctx context.Context, proc string, args ...string) error {
	placeholders := make([]string, len(args))
	iargs := make([]any, len(args))
	for j, a := range args {
		placeholders[j] = "?"
		iargs[j] = a
	}
	query := "CALL " + proc + "(" + strings.Join(placeholders, ", ") + ")"
	if _, err := i.runner.ExecContext(ctx, query, iargs...); err != nil {
		return fmt.Errorf("db: %s: %w", proc, err)
	}
	return nil
}

View on GitHub (pinned to 71377f2769)

Solutions

  1. Read the wrapped driver error: it names the procedure and its internal failure reason
  2. Upgrade the Dolt server to match the version beads expects (missing-procedure errors indicate version skew)
  3. Check preconditions before the call (branch exists, clean working set for checkout/merge)
  4. Retry on transient connection errors; recreate the session if the pool went stale

Example fix

// before
if err := conn.Branch(ctx, "feature"); err != nil { log.Fatal(err) }
// after
if err := conn.Branch(ctx, "feature"); err != nil {
    if strings.Contains(err.Error(), "already exists") { /* handle */ }
    log.Fatalf("branch op failed: %v", err)
}
Defensive patterns

Strategy: try-catch

Validate before calling

// verify server supports the procedure before calling
var one int
if err := db.QueryRow("SELECT 1 FROM information_schema.routines WHERE routine_name = 'dolt_merge'").Scan(&one); err != nil {
    return fmt.Errorf("dolt_merge unavailable on this server version")
}

Type guard

func isProcMissingErr(err error) bool {
    return strings.Contains(err.Error(), "does not exist") || strings.Contains(err.Error(), "unknown procedure")
}

Try / catch

if err := conn.Commit(ctx, msg); err != nil {
    if isProcMissingErr(err) { return upgradeDoltServer() }
    if strings.Contains(err.Error(), "conflict") { return handleMergeConflict() }
    return fmt.Errorf("dolt commit failed: %w", err)
}

Prevention

When it happens

Trigger: Calling Checkout, Branch, Add, Commit, Merge, or Remote when the CALL statement fails: unknown procedure (older Dolt server version), wrong argument types/counts, procedure internal failure (merge conflict, checkout with dirty working set, branch already exists), or connection loss.

Common situations: Dolt server version mismatch where a newer beads expects a procedure the server doesn't have; dolt_merge failing on conflicts; dolt_branch on an existing branch name; dolt_checkout failing due to uncommitted changes.

Related errors


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