gastownhall/beads · error

dolt reset %s: %w

Error message

dolt reset %s: %w

What it means

unstagePreExistingTables unstages user-staged tables (found via dolt_status) with `CALL DOLT_RESET(?)` before migrations run, so the migration pass commits only its own changes. If DOLT_RESET fails for a given table, the error is wrapped as "dolt reset <table>: %w" and MigrateUp aborts before any migration step, preserving the user's staged state.

Source

Thrown at internal/storage/schema/schema.go:800

func stagedDirtyTables(tables map[string]dirtyTableState) []string {
	var staged []string
	for table, state := range tables {
		if state.staged {
			staged = append(staged, table)
		}
	}
	sort.Strings(staged)
	return staged
}

func unstagePreExistingTables(ctx context.Context, db DBConn, tables map[string]dirtyTableState) error {
	staged := stagedDirtyTables(tables)
	if len(staged) > 0 {
		log.Printf("schema migration unstaging pre-existing staged tables: %s", strings.Join(staged, ", "))
	}
	for _, table := range staged {
		if err := DrainCall(ctx, db, "CALL DOLT_RESET(?)", table); err != nil {
			return fmt.Errorf("dolt reset %s: %w", table, err)
		}
	}
	return nil
}

func unstageIgnoredTables(ctx context.Context, db DBConn) error {
	tables, err := existingIgnoredTables(ctx, db)
	if err != nil {
		return err
	}
	return unstagePreExistingTables(ctx, db, tables)
}

func dirtyTableSignatures(ctx context.Context, db DBConn, tables map[string]dirtyTableState) (map[string]string, error) {
	signatures := make(map[string]string, len(tables))
	names := sortedDirtyTableNames(tables)
	for _, table := range names {
		signature, err := dirtyTableSignature(ctx, db, table)

View on GitHub (pinned to 71377f2769)

Solutions

  1. Read the wrapped cause for the specific table; check `dolt status` inside the .beads Dolt directory to see what is staged.
  2. Resolve any merge conflicts Dolt reports (dolt conflicts / dolt conflicts resolve), then retry `bd`.
  3. If the staged changes are unwanted, manually run `dolt reset <table>` (or `dolt checkout <table>`) in the database directory and retry.
  4. Ensure no concurrent `bd`/`dolt` process is mutating the working set while migrations run (use MigrateUpWithLock).
  5. Verify disk permissions and that the embedded Dolt engine can write to the database directory.

Example fix

// before: migration aborts on a staged table
_, err := schema.MigrateUp(ctx, db)
// after: unstage/pre-clean the working set through dolt CLI first, then migrate
//   cd .beads && dolt reset
_, err = schema.MigrateUp(ctx, db)
Defensive patterns

Strategy: validation

Validate before calling

// Go: pre-check for staged tables via dolt_status before calling MigrateUp
rows, err := db.QueryContext(ctx, "SELECT table_name, staged FROM dolt_status")
if err != nil { return err }
for rows.Next() {
    var name string; var staged bool
    if err := rows.Scan(&name, &staged); err != nil { return err }
    if staged {
        return fmt.Errorf("table %s is staged; run dolt reset before migrating", name)
    }
}

Try / catch

err := schema.MigrateUp(ctx, db)
if err != nil && strings.HasPrefix(err.Error(), "dolt reset ") {
    // table name is between "dolt reset " and ": "
    table := strings.SplitN(strings.TrimPrefix(err.Error(), "dolt reset "), ":", 2)[0]
    _ = table // guide the user to run `dolt reset <table>` manually
}

Prevention

When it happens

Trigger: MigrateUp (or unstageIgnoredTables) finds tables already staged in dolt_status and issues DOLT_RESET per table; the reset fails — typically because the table name is problematic for the driver, the connection is broken, or the Dolt working set is in a state where reset is refused (e.g. mid-merge/conflict).

Common situations: A user (or another tool) ran `dolt add` inside the .beads database before running `bd`; a previous crashed process left tables staged; an embedded Dolt engine returned an unexpected error resetting a conflicted table; connection dropped between status read and reset.

Related errors


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