gastownhall/beads · error

db: GetConfig %s: %w

Error message

db: GetConfig %s: %w

What it means

This error wraps a failure of the SELECT used by GetConfig to read a config value from the config table. Missing rows are NOT errors — sql.ErrNoRows returns ("", nil) — so this wrapper only fires on genuine query failures: connection problems, a missing config table, or scan-level driver errors. It identifies which config key was being read.

Source

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

	}
	return value, nil
}

func (r *configSQLRepositoryImpl) SetLocalMetadata(ctx context.Context, key, value string) error {
	if _, err := r.runner.ExecContext(ctx, "REPLACE INTO local_metadata (`key`, value) VALUES (?, ?)", key, value); err != nil {
		return fmt.Errorf("db: SetLocalMetadata %s: %w", key, err)
	}
	return nil
}

func (r *configSQLRepositoryImpl) GetConfig(ctx context.Context, key string) (string, error) {
	var value string
	err := r.runner.QueryRowContext(ctx, "SELECT value FROM config WHERE `key` = ?", key).Scan(&value)
	if errors.Is(err, sql.ErrNoRows) {
		return "", nil
	}
	if err != nil {
		return "", fmt.Errorf("db: GetConfig %s: %w", key, err)
	}
	return value, nil
}

func (r *configSQLRepositoryImpl) SetConfig(ctx context.Context, key, value string) error {
	if key == "issue_prefix" {
		value = strings.TrimSuffix(value, "-")
	}
	if _, err := r.runner.ExecContext(ctx, "REPLACE INTO config (`key`, value) VALUES (?, ?)", key, value); err != nil {
		return fmt.Errorf("db: SetConfig %s: %w", key, err)
	}
	// Re-sync the normalized lookup table a value backs, mirroring
	// DoltStore.SetConfig. Reads are TABLE-FIRST — GetCustomTypes above
	// consults custom_types and falls back to the string only when the table is
	// empty, and GetCustomStatuses reads custom_statuses outright — so a write
	// that updated only the string left the table holding the previous set,
	// forever: `bd config set types.custom` on a proxied deployment reported
	// success and `bd create -t <the new type>` kept answering "invalid issue

View on GitHub (pinned to 71377f2769)

Solutions

  1. Read the wrapped cause: if it is 'no such table: config', run schema setup/migration before use
  2. Check for and clear competing locks on the Dolt database, then retry
  3. Verify disk space, permissions, and database file integrity
  4. If the context deadline was exceeded, increase the timeout or check database responsiveness
  5. Restore the database from backup if corruption is indicated
Defensive patterns

Strategy: fallback

Validate before calling

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

Try / catch

val, err := repo.GetConfig(ctx, key)
if err != nil {
	if errors.Is(err, context.DeadlineExceeded) {
		val = defaultFor(key) // fall back to default on timeout
	} else {
		return fmt.Errorf("reading config %q: %w", key, err)
	}
}

Prevention

When it happens

Trigger: Calling GetConfig (directly or via readCustomTypesConfig, GetAllowedPrefixes, GetAdaptiveIDConfig, GetInfraTypes) when the SELECT value FROM config query fails — config table absent, database locked/unreachable, or context canceled mid-query.

Common situations: Opening a repo whose schema predates the config table; database file locked by another bd process; context deadline exceeded during a slow query; corrupted database file.

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/c01f4bbe82c33b32. Report an issue: GitHub.