gastownhall/beads · error
failed to get config: %w
Error message
failed to get config: %w
What it means
Reading the issue_prefix row from the config table failed with a database error that is neither 'no rows' nor an empty value — i.e. the lookup itself failed. Unlike the ErrNotInitialized case, this indicates a storage problem rather than missing configuration.
Source
Thrown at internal/storage/issueops/helpers.go:529
return false
}
s := strings.ToLower(err.Error())
return strings.Contains(s, "nothing to commit") ||
(strings.Contains(s, "no changes") && strings.Contains(s, "commit"))
}
// ReadConfigPrefix reads and normalizes issue_prefix from the config table.
func ReadConfigPrefix(ctx context.Context, tx DBTX) (string, error) {
var configPrefix string
err := tx.QueryRowContext(ctx, "SELECT value FROM config WHERE `key` = ?", "issue_prefix").Scan(&configPrefix)
if err == sql.ErrNoRows || configPrefix == "" {
yamlPrefix := strings.TrimSpace(config.GetString("issue-prefix"))
underscoreYamlPrefix := strings.TrimSpace(config.GetString("issue_prefix"))
debug.Logf("Debug: missing config.issue_prefix in database (err=%v, db value=%q, yaml issue-prefix=%q, yaml issue_prefix=%q)\n",
err, configPrefix, yamlPrefix, underscoreYamlPrefix)
return "", fmt.Errorf("%w: issue_prefix config is missing (run 'bd init --prefix <prefix>' for a new project, or 'bd bootstrap' to clone an existing remote; if using config.yaml, use key 'issue-prefix', not 'issue_prefix')", storage.ErrNotInitialized)
} else if err != nil {
return "", fmt.Errorf("failed to get config: %w", err)
}
return strings.TrimSuffix(configPrefix, "-"), nil
}
// ---------------------------------------------------------------------------
// Nullable value helpers
// ---------------------------------------------------------------------------
// NullString returns nil for empty strings, otherwise the string value.
func NullString(s string) interface{} {
if s == "" {
return nil
}
return s
}
// NullStringPtr returns nil for nil pointers, otherwise the pointed-to string.
func NullStringPtr(s *string) interface{} {View on GitHub (pinned to 71377f2769)
Solutions
- Check the wrapped error and Dolt server logs for the underlying cause (lock, I/O, connection).
- Retry the command — this is often transient; if it recurs, test with a direct query: SELECT value FROM config WHERE `key`='issue_prefix'.
- Verify the .beads database isn't locked/corrupted; try `bd doctor` or re-clone via 'bd bootstrap'.
- Ensure network/server stability if using a remote Dolt endpoint; increase timeouts if deadlines are involved.
Example fix
// before: one-shot call that fails hard on a transient DB hiccup
prefix, err := storage.ReadConfigPrefix(ctx, tx)
// after: retry transient failures
var prefix string
err := retry.Do(func() error { p, e := storage.ReadConfigPrefix(ctx, tx); prefix = p; return e }, retry.Attempts(3)) Defensive patterns
Strategy: retry
Validate before calling
if err := ctx.Err(); err != nil {
return fmt.Errorf("context already cancelled/expired before config read: %w", err)
}
if err := db.PingContext(ctx); err != nil {
return fmt.Errorf("database unreachable before config read: %w", err)
} Try / catch
prefix, err := storage.ReadConfigPrefix(ctx, tx)
if err != nil && !errors.Is(err, storage.ErrNotInitialized) {
// transient DB failure — retry with backoff in a fresh tx
return retry.Do(func() error { return readPrefixAndRun(ctx) }, retry.Attempts(3))
} Prevention
- Ping the database (or run a trivial SELECT 1) before issuing storage commands in scripts.
- Set realistic context timeouts for slow or remote Dolt connections.
- Watch dolt sql-server logs for locks, restarts, and I/O errors.
- Avoid concurrent processes holding long write locks on the same .beads database.
When it happens
Trigger: ReadConfigPrefix's SELECT value FROM config WHERE `key` = 'issue_prefix' fails: connection dropped, Dolt server error, locked database, corrupted config table, or context cancellation during the query.
Common situations: Dolt server restarting during a bd command; .beads database locked by another long-running process; disk I/O errors; context deadline exceeded on a slow remote Dolt connection.
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
- ErrQuery
- failed to get federation peer: %w
- db: CommentSQLRepository.CountsByIssueIDs: %w
- db: CommentSQLRepository.ListByIssueIDs: %w
- db: LabelSQLRepository.ListByIssueIDs: %w
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/5351462f938e058b.
Report an issue: GitHub.