gastownhall/beads · error

inserting status %q: %w

Error message

inserting status %q: %w

What it means

This error wraps a failed INSERT IGNORE INTO custom_statuses (name, category) while seeding custom statuses from configuration during migration. Since INSERT IGNORE absorbs duplicates, the wrapped cause is a genuine SQL failure such as a missing table, denied privilege, connection loss, or cancellation. Raised by backfillCustomStatuses during MigrateUp.

Source

Thrown at internal/storage/schema/backfill.go:151

		return false, nil
	}
	if err != nil {
		return false, err
	}
	if value == "" {
		return false, nil
	}

	parsed, parseErr := types.ParseCustomStatusConfig(value)
	if parseErr != nil {
		log.Printf("schema: skipping invalid status.custom entries: %v", parseErr)
		return false, nil
	}
	wrote := false
	for _, s := range parsed {
		res, err := db.ExecContext(ctx, "INSERT IGNORE INTO custom_statuses (name, category) VALUES (?, ?)", s.Name, string(s.Category))
		if err != nil {
			return wrote, fmt.Errorf("inserting status %q: %w", s.Name, err)
		}
		if n, err := res.RowsAffected(); err == nil && n > 0 {
			wrote = true
		}
	}
	return wrote, nil
}

View on GitHub (pinned to 71377f2769)

Solutions

  1. Run the complete migration flow so custom_statuses is created, then retry MigrateUp.
  2. Grant the DB user INSERT on custom_statuses.
  3. Re-establish Dolt connectivity and re-run; the backfill is count-gated and safe to repeat.
  4. Inspect the wrapped driver error to identify the exact failing statement.
Defensive patterns

Strategy: retry

Validate before calling

// Confirm custom_statuses exists and is writable before backfill
var n int
if err := db.QueryRowContext(ctx, `SELECT COUNT(*) FROM information_schema.TABLES WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'custom_statuses'`).Scan(&n); err != nil || n == 0 {
	return fmt.Errorf("custom_statuses missing; run migrations")
}
// privilege probe (harmless insert rolled back in a txn)
tx, _ := db.BeginTx(ctx, nil)
_, err := tx.ExecContext(ctx, "INSERT IGNORE INTO custom_statuses (name, category) VALUES ('__probe__','open')")
tx.Rollback()

Try / catch

err := migrateUp(ctx)
if err != nil && strings.Contains(err.Error(), "inserting status ") {
	if isTransient(err) {
		err = migrateUp(ctx)
	}
}

Prevention

When it happens

Trigger: The per-status INSERT IGNORE in backfillCustomStatuses returns a driver error: custom_statuses table absent (migrations not run), INSERT privilege denied, context cancelled, or connection dropped mid-loop.

Common situations: Partially migrated database; restricted DB user; Dolt server restart during upgrade; custom_statuses locked by another session.

Related errors


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