{"record":{"id":"7f836a5d0b5d34b4","repo":"gastownhall/beads","slug":"failed-to-read-issue-id-mode-config-w","errorCode":null,"errorMessage":"failed to read issue_id_mode config: %w","messagePattern":"failed to read issue_id_mode config: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/dolt/issues.go","lineNumber":907,"sourceCode":"\t\t\t}\n\t\t}\n\t}\n\n\t// Read back the value that was atomically set by the DB engine.\n\tvar nextID int\n\terr = tx.QueryRowContext(ctx, \"SELECT last_id FROM issue_counter WHERE prefix = ?\", prefix).Scan(&nextID)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to read issue counter after increment for prefix %q: %w\", prefix, err)\n\t}\n\treturn fmt.Sprintf(\"%s-%d\", prefix, nextID), nil\n}\n\n// isCounterModeTx checks whether issue_id_mode=counter is configured.\nfunc isCounterModeTx(ctx context.Context, tx *sql.Tx) (bool, error) {\n\tvar idMode string\n\terr := tx.QueryRowContext(ctx, \"SELECT value FROM config WHERE `key` = ?\", \"issue_id_mode\").Scan(&idMode)\n\tif err != nil && err != sql.ErrNoRows {\n\t\treturn false, fmt.Errorf(\"failed to read issue_id_mode config: %w\", err)\n\t}\n\treturn idMode == \"counter\", nil\n}\n\n// generateHashID creates a hash-based ID for a top-level issue.\n// Uses base36 encoding (0-9, a-z) for better information density than hex.\nfunc generateHashID(prefix, title, description, creator string, timestamp time.Time, length, nonce int) string {\n\treturn idgen.GenerateHashID(prefix, title, description, creator, timestamp, length, nonce)\n}\n\n// Thin wrappers around exported issueops functions, kept for internal callers.\nvar (\n\tisAllowedUpdateField = issueops.IsAllowedUpdateField\n)\n\n// Aliases for shared nullable helpers from issueops.\nvar (\n\tnullString    = issueops.NullString","sourceCodeStart":889,"sourceCodeEnd":925,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/dolt/issues.go#L889-L925","documentation":"isCounterModeTx reads the `issue_id_mode` key from the config table to decide whether to use counter-based IDs. This error wraps a failure reading that config row other than 'row not found' (ErrNoRows is treated as non-counter mode). It means the config table is unreadable, missing, or the query failed for connection/transaction reasons.","triggerScenarios":"Any issue-ID generation when the `SELECT value FROM config WHERE key = 'issue_id_mode'` fails: config table absent from an old schema, corrupted database, cancelled context, or transaction/connection error.","commonSituations":"Very old beads databases that predate the config table; a corrupt .beads database; a context timeout hitting during repository open; Dolt server unavailable mid-transaction.","solutions":["Inspect the wrapped cause; if the config table is missing, run the beads schema migration to create it.","Re-run after confirming the Dolt backend is reachable and the context deadline is sufficient.","Create the config row explicitly (INSERT INTO config (key, value) VALUES ('issue_id_mode','counter')) to force counter mode once the table exists.","Run bd doctor to diagnose database corruption if errors persist."],"exampleFix":"// before\nerr := tx.QueryRowContext(ctx, \"SELECT value FROM config WHERE `key` = ?\", \"issue_id_mode\").Scan(&idMode)\nif err != nil && err != sql.ErrNoRows {\n    return false, fmt.Errorf(\"failed to read issue_id_mode config: %w\", err)\n}\n// after (fail with actionable hint)\nerr := tx.QueryRowContext(ctx, \"SELECT value FROM config WHERE `key` = ?\", \"issue_id_mode\").Scan(&idMode)\nif err != nil && err != sql.ErrNoRows {\n    if errors.Is(err, sql.ErrNoRows) { /* unreachable, kept for clarity */ }\n    return false, fmt.Errorf(\"failed to read issue_id_mode config (is the config table migrated?): %w\", err)\n}","handlingStrategy":"validation","validationCode":"var val string\nerr := db.QueryRow(\"SELECT value FROM config WHERE `key` = 'issue_id_mode'\").Scan(&val)\nif err != nil {\n    if errors.Is(err, sql.ErrNoRows) { /* default mode, fine */ } else {\n        return fmt.Errorf(\"config table unreadable; run schema migration: %w\", err)\n    }\n}","typeGuard":"func isConfigReadErr(err error) bool {\n    return err != nil && strings.Contains(err.Error(), \"issue_id_mode config\") && !errors.Is(err, sql.ErrNoRows)\n}","tryCatchPattern":"id, err := store.CreateIssue(ctx, issue)\nif err != nil && strings.Contains(err.Error(), \"read issue_id_mode config\") {\n    return fmt.Errorf(\"config table problem; run bd doctor / schema migration: %w\", err)\n}","preventionTips":["Run schema migrations whenever beads is upgraded","Set issue_id_mode explicitly after initial setup to verify the config table works","Run bd doctor after database restores or imports","Ensure contexts have adequate deadlines when opening large repositories"],"tags":["database","config","counter-mode"],"backgroundTag":"config-read-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}