{"record":{"id":"5351462f938e058b","repo":"gastownhall/beads","slug":"failed-to-get-config-w","errorCode":null,"errorMessage":"failed to get config: %w","messagePattern":"failed to get config: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/issueops/helpers.go","lineNumber":529,"sourceCode":"\t\treturn false\n\t}\n\ts := strings.ToLower(err.Error())\n\treturn strings.Contains(s, \"nothing to commit\") ||\n\t\t(strings.Contains(s, \"no changes\") && strings.Contains(s, \"commit\"))\n}\n\n// ReadConfigPrefix reads and normalizes issue_prefix from the config table.\nfunc ReadConfigPrefix(ctx context.Context, tx DBTX) (string, error) {\n\tvar configPrefix string\n\terr := tx.QueryRowContext(ctx, \"SELECT value FROM config WHERE `key` = ?\", \"issue_prefix\").Scan(&configPrefix)\n\tif err == sql.ErrNoRows || configPrefix == \"\" {\n\t\tyamlPrefix := strings.TrimSpace(config.GetString(\"issue-prefix\"))\n\t\tunderscoreYamlPrefix := strings.TrimSpace(config.GetString(\"issue_prefix\"))\n\t\tdebug.Logf(\"Debug: missing config.issue_prefix in database (err=%v, db value=%q, yaml issue-prefix=%q, yaml issue_prefix=%q)\\n\",\n\t\t\terr, configPrefix, yamlPrefix, underscoreYamlPrefix)\n\t\treturn \"\", 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)\n\t} else if err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to get config: %w\", err)\n\t}\n\treturn strings.TrimSuffix(configPrefix, \"-\"), nil\n}\n\n// ---------------------------------------------------------------------------\n// Nullable value helpers\n// ---------------------------------------------------------------------------\n\n// NullString returns nil for empty strings, otherwise the string value.\nfunc NullString(s string) interface{} {\n\tif s == \"\" {\n\t\treturn nil\n\t}\n\treturn s\n}\n\n// NullStringPtr returns nil for nil pointers, otherwise the pointed-to string.\nfunc NullStringPtr(s *string) interface{} {","sourceCodeStart":511,"sourceCodeEnd":547,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/issueops/helpers.go#L511-L547","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before: one-shot call that fails hard on a transient DB hiccup\nprefix, err := storage.ReadConfigPrefix(ctx, tx)\n// after: retry transient failures\nvar prefix string\nerr := retry.Do(func() error { p, e := storage.ReadConfigPrefix(ctx, tx); prefix = p; return e }, retry.Attempts(3))","handlingStrategy":"retry","validationCode":"if err := ctx.Err(); err != nil {\n    return fmt.Errorf(\"context already cancelled/expired before config read: %w\", err)\n}\nif err := db.PingContext(ctx); err != nil {\n    return fmt.Errorf(\"database unreachable before config read: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"prefix, err := storage.ReadConfigPrefix(ctx, tx)\nif err != nil && !errors.Is(err, storage.ErrNotInitialized) {\n    // transient DB failure — retry with backoff in a fresh tx\n    return retry.Do(func() error { return readPrefixAndRun(ctx) }, retry.Attempts(3))\n}","preventionTips":["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."],"tags":["database","config","query","go"],"backgroundTag":"sql-query-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}