gastownhall/beads · error
db: GetCustomTypes: query custom_types: %w
Error message
db: GetCustomTypes: query custom_types: %w
What it means
This error wraps failure of the SELECT used by readCustomTypesTable to load custom issue types from the custom_types table. A missing table is handled gracefully (IsTableNotExist returns nil, nil) so this error only fires for genuine query failures — locking, connection, context, or driver errors. GetCustomTypes treats an empty/missing table as a signal to fall back to the config string.
Source
Thrown at internal/storage/domain/db/config.go:153
fromDB := fromTable
if len(fromDB) == 0 {
fromConfig, err := r.readCustomTypesConfig(ctx)
if err != nil {
return nil, err
}
fromDB = fromConfig
}
return unionWithYAMLCustomTypes(fromDB, config.GetCustomTypesFromYAML()), nil
}
func (r *configSQLRepositoryImpl) readCustomTypesTable(ctx context.Context) ([]string, error) {
rows, err := r.runner.QueryContext(ctx, "SELECT name FROM custom_types ORDER BY name")
if err != nil {
if dberrors.IsTableNotExist(err) {
return nil, nil
}
return nil, fmt.Errorf("db: GetCustomTypes: query custom_types: %w", err)
}
defer rows.Close()
var out []string
for rows.Next() {
var name string
if err := rows.Scan(&name); err != nil {
return nil, fmt.Errorf("db: GetCustomTypes: scan custom_types: %w", err)
}
if name = strings.TrimSpace(name); name != "" {
out = append(out, name)
}
}
if err := rows.Err(); err != nil {
return nil, fmt.Errorf("db: GetCustomTypes: read custom_types: %w", err)
}
return out, nil
}
View on GitHub (pinned to 71377f2769)
Solutions
- Check the wrapped cause; if it is a table-existence variant on an old schema, run migration
- Clear competing database locks and retry
- Retry with a longer context timeout if the deadline was exceeded
- Verify database integrity; restore from backup if corrupted
- Note that a missing table is NOT this error — empty result triggers the config-string fallback instead
Defensive patterns
Strategy: fallback
Validate before calling
if !tableExists(ctx, "custom_types") {
// repository itself falls back to the config string; callers may do the same
} Try / catch
types, err := repo.GetCustomTypes(ctx)
if err != nil {
if isTransient(err) {
types, err = repo.GetCustomTypes(ctx) // one retry
}
if err != nil {
return fmt.Errorf("loading custom types: %w", err)
}
} Prevention
- A missing custom_types table is not this error — the repo falls back to the config string automatically
- Migrate schema after bd upgrades
- Retry transient lock/connection failures; type listing is read-only
- Use adequate context timeouts on schema queries
When it happens
Trigger: GetCustomTypes → readCustomTypesTable when SELECT name FROM custom_types ORDER BY name fails with an error other than table-not-exist: database locked, connection dropped, context canceled, or a driver error unrelated to table existence.
Common situations: Listing issue types on a repo whose Dolt database is locked by another process; context deadline exceeded during schema listing; corrupted database; a driver error misreported as something other than table-not-exist on very old schemas.
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/3117977971e9156d.
Report an issue: GitHub.