{"record":{"id":"a42008a0e6e0f562","repo":"gastownhall/beads","slug":"db-getcustomtypes-read-custom-types-w","errorCode":null,"errorMessage":"db: GetCustomTypes: read custom_types: %w","messagePattern":"db: GetCustomTypes: read custom_types: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/domain/db/config.go","lineNumber":167,"sourceCode":"\tif err != nil {\n\t\tif dberrors.IsTableNotExist(err) {\n\t\t\treturn nil, nil\n\t\t}\n\t\treturn nil, fmt.Errorf(\"db: GetCustomTypes: query custom_types: %w\", err)\n\t}\n\tdefer rows.Close()\n\tvar out []string\n\tfor rows.Next() {\n\t\tvar name string\n\t\tif err := rows.Scan(&name); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"db: GetCustomTypes: scan custom_types: %w\", err)\n\t\t}\n\t\tif name = strings.TrimSpace(name); name != \"\" {\n\t\t\tout = append(out, name)\n\t\t}\n\t}\n\tif err := rows.Err(); err != nil {\n\t\treturn nil, fmt.Errorf(\"db: GetCustomTypes: read custom_types: %w\", err)\n\t}\n\treturn out, nil\n}\n\nfunc (r *configSQLRepositoryImpl) readCustomTypesConfig(ctx context.Context) ([]string, error) {\n\tvalue, err := r.GetConfig(ctx, \"types.custom\")\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"db: GetCustomTypes: %w\", err)\n\t}\n\treturn issueops.ParseTypesConfigValue(value), nil\n}\n\nfunc unionWithYAMLCustomTypes(dbTypes, yamlTypes []string) []string {\n\tif len(dbTypes) == 0 && len(yamlTypes) == 0 {\n\t\treturn nil\n\t}\n\tseen := make(map[string]struct{}, len(dbTypes)+len(yamlTypes))\n\tout := make([]string, 0, len(dbTypes)+len(yamlTypes))","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/domain/db/config.go#L149-L185","documentation":"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.","triggerScenarios":"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.","commonSituations":"Network interruptions to a remote Dolt server, context cancellation/timeouts during slow queries, connection pool exhaustion, or the server restarting mid-query.","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."],"exampleFix":"// before\nout, err := store.GetCustomTypes(ctx) // ctx already near deadline\n// after\nqctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)\ndefer cancel()\nout, err := store.GetCustomTypes(qctx)\nif err != nil {\n    if errors.Is(err, context.DeadlineExceeded) { /* retry or raise timeout */ }\n}","handlingStrategy":"retry","validationCode":"// No pre-call validation possible; ensure a healthy connection and live context first.\nif err := conn.PingContext(ctx); err != nil {\n    return fmt.Errorf(\"database unavailable: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"out, err := store.GetCustomTypes(ctx)\nif err != nil {\n    if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {\n        return retryWithFreshContext()\n    }\n    return fmt.Errorf(\"read custom types: %w\", err)\n}","preventionTips":["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."],"tags":["database","query-iteration","connection"],"backgroundTag":"row-iteration-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}