gastownhall/beads · error

custom_statuses: %w

Error message

custom_statuses: %w

What it means

Wrapper from needsBackfilledCustomStatusesCustomTypes when the probe needsCustomStatusesBackfill fails, during migrationWorkNeeded evaluation. The probe issues SELECT COUNT(*) FROM custom_statuses and a config lookup; any SQL error is wrapped so callers of migrationWorkNeeded can distinguish 'work needed' from 'cannot determine'.

Source

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

	typesWrote, err := backfillCustomTypes(ctx, db)
	if err != nil {
		return typesWrote, fmt.Errorf("backfill custom_types: %w", err)
	}
	statusesWrote, err := backfillCustomStatuses(ctx, db)
	if err != nil {
		return typesWrote || statusesWrote, fmt.Errorf("backfill custom_statuses: %w", err)
	}
	return typesWrote || statusesWrote, nil
}

func needsBackfilledCustomStatusesCustomTypes(ctx context.Context, db DBConn) (bool, error) {
	typesNeed, err := needsCustomTypesBackfill(ctx, db)
	if err != nil {
		return false, fmt.Errorf("custom_types: %w", err)
	}
	statusesNeed, err := needsCustomStatusesBackfill(ctx, db)
	if err != nil {
		return false, fmt.Errorf("custom_statuses: %w", err)
	}
	return typesNeed || statusesNeed, nil
}

func needsCustomTypesBackfill(ctx context.Context, db DBConn) (bool, error) {
	var count int
	if err := db.QueryRowContext(ctx, "SELECT COUNT(*) FROM custom_types").Scan(&count); err != nil {
		return false, err
	}
	if count > 0 {
		return false, nil
	}

	var value string
	err := db.QueryRowContext(ctx, "SELECT `value` FROM config WHERE `key` = 'types.custom'").Scan(&value)
	if err == sql.ErrNoRows {
		return false, nil
	}

View on GitHub (pinned to 71377f2769)

Solutions

  1. Complete the MigrateUp flow so all tables are created, then re-open.
  2. Verify Dolt server connectivity and retry.
  3. Grant SELECT on custom_statuses and config to the DB user.
  4. Check the wrapped cause for the precise statement and schema state.
Defensive patterns

Strategy: retry

Validate before calling

// Detect a fresh database before probing backfill need
var n int
err := db.QueryRowContext(ctx, `SELECT COUNT(*) FROM information_schema.TABLES WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'custom_statuses'`).Scan(&n)
if err == nil && n == 0 {
	// schema not created yet — run MigrateUp instead of probing
}

Try / catch

err := openAndMigrate(ctx)
if err != nil && strings.Contains(err.Error(), "custom_statuses:") {
	if isMissingTableErr(err) || isTransient(err) {
		err = openAndMigrate(ctx)
	}
}

Prevention

When it happens

Trigger: needsCustomStatusesBackfill's SELECT COUNT(*) FROM custom_statuses or its config read fails — missing table on a fresh or partial database, cancelled context, connection loss, or missing SELECT privilege.

Common situations: Opening a brand-new database before migrations run; mid-upgrade database missing custom_statuses; network interruption to the Dolt server; DB user restrictions.

Related errors


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