gastownhall/beads · error

db: GetAllConfig: %w

Error message

db: GetAllConfig: %w

What it means

This error wraps failure of the query that enumerates all config rows in GetAllConfig. It fires when the SELECT `key`, value FROM config statement itself fails, before any row iteration begins. Row-scan and iteration errors are reported by the separate scan and read wrappers.

Source

Thrown at internal/storage/domain/db/config.go:112

	// The caller supplies a transactional runner, so the row and its projection
	// commit together or neither does.
	if _, err := issueops.SyncConfigTables(ctx, r.runner, key, value); err != nil {
		return fmt.Errorf("db: SetConfig %s: %w", key, err)
	}
	return nil
}

func (r *configSQLRepositoryImpl) DeleteConfig(ctx context.Context, key string) error {
	if _, err := r.runner.ExecContext(ctx, "DELETE FROM config WHERE `key` = ?", key); err != nil {
		return fmt.Errorf("db: DeleteConfig %s: %w", key, err)
	}
	return nil
}

func (r *configSQLRepositoryImpl) GetAllConfig(ctx context.Context) (map[string]string, error) {
	rows, err := r.runner.QueryContext(ctx, "SELECT `key`, value FROM config")
	if err != nil {
		return nil, fmt.Errorf("db: GetAllConfig: %w", err)
	}
	defer rows.Close()
	out := make(map[string]string)
	for rows.Next() {
		var k, v string
		if err := rows.Scan(&k, &v); err != nil {
			return nil, fmt.Errorf("db: GetAllConfig: scan: %w", err)
		}
		out[k] = v
	}
	if err := rows.Err(); err != nil {
		return nil, fmt.Errorf("db: GetAllConfig: read: %w", err)
	}
	return out, nil
}

func (r *configSQLRepositoryImpl) GetCustomTypes(ctx context.Context) ([]string, error) {
	fromTable, err := r.readCustomTypesTable(ctx)

View on GitHub (pinned to 71377f2769)

Solutions

  1. Check the wrapped cause; run schema migration if the config table is missing
  2. Clear competing database locks and retry
  3. Increase the operation timeout if the context deadline was exceeded
  4. Verify database file integrity and disk health
  5. Restore from backup if the database is corrupted
Defensive patterns

Strategy: try-catch

Validate before calling

if err := ensureSchemaMigrated(ctx); err != nil {
	return fmt.Errorf("config table unavailable: %w", err)
}

Try / catch

all, err := repo.GetAllConfig(ctx)
if err != nil {
	if errors.Is(err, context.DeadlineExceeded) {
		return nil, fmt.Errorf("config listing timed out; increase timeout")
	}
	return nil, fmt.Errorf("listing config: %w", err)
}

Prevention

When it happens

Trigger: Calling GetAllConfig(ctx) when QueryContext fails: config table missing from the schema, database locked or unreachable, connection dropped, or context canceled before the query starts returning.

Common situations: Opening a repo with an old schema lacking the config table; `bd config list` against a locked or corrupted database; context deadline exceeded on a large/slow Dolt database.

Understand the failure class

Background: "query failed", "%w: SQL error" — wrapped database query errors in Go libraries explained — this error's family across 3 libraries.

Related errors


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