gastownhall/beads · error
db: GetCustomTypes: read custom_types: %w
Error message
db: GetCustomTypes: read custom_types: %w
What it means
This error wraps a failure that occurred while iterating result rows of the `SELECT name FROM custom_types` query in readCustomTypesTable, surfaced by rows.Err() after the scan loop. It is thrown by GetCustomTypes when the underlying driver/connection hits a mid-iteration error (connection drop, query cancelled, driver-level fault). A missing custom_types table is tolerated (returns nil), so this error only fires on real I/O or driver failures.
Source
Thrown at internal/storage/domain/db/config.go:167
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
}
func (r *configSQLRepositoryImpl) readCustomTypesConfig(ctx context.Context) ([]string, error) {
value, err := r.GetConfig(ctx, "types.custom")
if err != nil {
return nil, fmt.Errorf("db: GetCustomTypes: %w", err)
}
return issueops.ParseTypesConfigValue(value), nil
}
func unionWithYAMLCustomTypes(dbTypes, yamlTypes []string) []string {
if len(dbTypes) == 0 && len(yamlTypes) == 0 {
return nil
}
seen := make(map[string]struct{}, len(dbTypes)+len(yamlTypes))
out := make([]string, 0, len(dbTypes)+len(yamlTypes))View on GitHub (pinned to 71377f2769)
Solutions
- Inspect the wrapped (%w) cause with errors.Unwrap/errors.Is to identify the driver error (connection reset, context cancelled, etc.).
- Check connectivity to the Dolt/MySQL server and retry; transient drops are the usual cause.
- If context timeouts cause it, raise the caller's timeout or move the read off the deadline-bound context.
- Verify the database schema is intact (custom_types table exists and is readable) with a manual query.
Example fix
// before
out, err := store.GetCustomTypes(ctx) // ctx already near deadline
// after
qctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
out, err := store.GetCustomTypes(qctx)
if err != nil {
if errors.Is(err, context.DeadlineExceeded) { /* retry or raise timeout */ }
} Defensive patterns
Strategy: retry
Validate before calling
// No pre-call validation possible; ensure a healthy connection and live context first.
if err := conn.PingContext(ctx); err != nil {
return fmt.Errorf("database unavailable: %w", err)
} Try / catch
out, err := store.GetCustomTypes(ctx)
if err != nil {
if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {
return retryWithFreshContext()
}
return fmt.Errorf("read custom types: %w", err)
} Prevention
- Ping the database before long-running operations to catch dead connections early.
- Use contexts with adequate timeouts for remote Dolt servers.
- Enable driver-level connection retry/pool health checks.
- Treat transient driver errors as retryable; classify with errors.Is before failing.
When it happens
Trigger: Calling GetCustomTypes when the Dolt/MySQL connection drops or the context is cancelled while rows from custom_types are being streamed; the table exists and the initial QueryContext succeeded, but rows.Next()/rows.Err() later reports a driver error.
Common situations: Network interruptions to a remote Dolt server, context cancellation/timeouts during slow queries, connection pool exhaustion, or the server restarting mid-query.
Related errors
- no database connection available (%s)
- dolt server connection failed: %w
- failed to reach the workspace identity: %v
- begin tx: %w
- begin read tx: %w
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/a42008a0e6e0f562.
Report an issue: GitHub.