{"record":{"id":"c01f4bbe82c33b32","repo":"gastownhall/beads","slug":"db-getconfig-s-w","errorCode":null,"errorMessage":"db: GetConfig %s: %w","messagePattern":"db: GetConfig (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/domain/db/config.go","lineNumber":73,"sourceCode":"\t}\n\treturn value, nil\n}\n\nfunc (r *configSQLRepositoryImpl) SetLocalMetadata(ctx context.Context, key, value string) error {\n\tif _, err := r.runner.ExecContext(ctx, \"REPLACE INTO local_metadata (`key`, value) VALUES (?, ?)\", key, value); err != nil {\n\t\treturn fmt.Errorf(\"db: SetLocalMetadata %s: %w\", key, err)\n\t}\n\treturn nil\n}\n\nfunc (r *configSQLRepositoryImpl) GetConfig(ctx context.Context, key string) (string, error) {\n\tvar value string\n\terr := r.runner.QueryRowContext(ctx, \"SELECT value FROM config WHERE `key` = ?\", key).Scan(&value)\n\tif errors.Is(err, sql.ErrNoRows) {\n\t\treturn \"\", nil\n\t}\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"db: GetConfig %s: %w\", key, err)\n\t}\n\treturn value, nil\n}\n\nfunc (r *configSQLRepositoryImpl) SetConfig(ctx context.Context, key, value string) error {\n\tif key == \"issue_prefix\" {\n\t\tvalue = strings.TrimSuffix(value, \"-\")\n\t}\n\tif _, err := r.runner.ExecContext(ctx, \"REPLACE INTO config (`key`, value) VALUES (?, ?)\", key, value); err != nil {\n\t\treturn fmt.Errorf(\"db: SetConfig %s: %w\", key, err)\n\t}\n\t// Re-sync the normalized lookup table a value backs, mirroring\n\t// DoltStore.SetConfig. Reads are TABLE-FIRST — GetCustomTypes above\n\t// consults custom_types and falls back to the string only when the table is\n\t// empty, and GetCustomStatuses reads custom_statuses outright — so a write\n\t// that updated only the string left the table holding the previous set,\n\t// forever: `bd config set types.custom` on a proxied deployment reported\n\t// success and `bd create -t <the new type>` kept answering \"invalid issue","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/domain/db/config.go#L55-L91","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Read the wrapped cause: if it is 'no such table: config', run schema setup/migration before use","Check for and clear competing locks on the Dolt database, then retry","Verify disk space, permissions, and database file integrity","If the context deadline was exceeded, increase the timeout or check database responsiveness","Restore the database from backup if corruption is indicated"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"if err := ensureSchemaMigrated(ctx); err != nil {\n\treturn fmt.Errorf(\"config table unavailable: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"val, err := repo.GetConfig(ctx, key)\nif err != nil {\n\tif errors.Is(err, context.DeadlineExceeded) {\n\t\tval = defaultFor(key) // fall back to default on timeout\n\t} else {\n\t\treturn fmt.Errorf(\"reading config %q: %w\", key, err)\n\t}\n}","preventionTips":["Remember empty-string return means 'not set'; only the wrapped error path signals failure","Run schema migrations after every bd upgrade","Set generous context timeouts for config reads on large databases","Do not open the same Dolt database with multiple writer processes"],"tags":["database","storage","dolt","read-failed"],"backgroundTag":"sql-query-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}