{"record":{"id":"f5effd6ea8131e22","repo":"gastownhall/beads","slug":"w-issue-prefix-config-is-missing-run-bd-init","errorCode":null,"errorMessage":"%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')","messagePattern":"%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'\\)","errorType":"exception","errorClass":"storage.ErrNotInitialized","httpStatus":null,"severity":"error","filePath":"internal/storage/issueops/helpers.go","lineNumber":527,"sourceCode":"func IsDoltNothingToCommit(err error) bool {\n\tif err == nil {\n\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","sourceCodeStart":509,"sourceCodeEnd":545,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/issueops/helpers.go#L509-L545","documentation":"The project is not initialized: there is no issue_prefix value in the database config table (or it is empty), so issue IDs cannot be generated. The error wraps storage.ErrNotInitialized and explains the exact remediation, including the common config.yaml key mistake ('issue_prefix' instead of 'issue-prefix').","triggerScenarios":"Running any command that needs an issue ID (bd create, etc.) via NewBatchContext/ReadConfigPrefix against a database where the config table lacks an issue_prefix row — fresh/uninitialized DB, config.yaml missing or using the wrong key, or a cloned repo without 'bd bootstrap'.","commonSituations":"Cloning a repo and skipping 'bd bootstrap'; writing `issue_prefix: PROJ` in config.yaml instead of `issue-prefix: PROJ`; running bd in a directory with no .beads database; a fresh checkout before 'bd init'.","solutions":["Run 'bd init --prefix <prefix>' in the repository to write issue_prefix into the database config.","If cloning an existing project's remote, run 'bd bootstrap' to pull config and data.","If configuring via config.yaml, rename the key to 'issue-prefix' (hyphen, not underscore): `issue-prefix: PROJ`.","Verify with `bd config get issue_prefix` (or inspect the config table) that a non-empty value is present before retrying."],"exampleFix":"// before: config.yaml\nissue_prefix: PROJ   # wrong key, ignored\n// after\nissue-prefix: PROJ\n// or, preferred: initialize the database config\n// $ bd init --prefix PROJ","handlingStrategy":"validation","validationCode":"func ensureInitialized(repoDir string) error {\n    if _, err := os.Stat(filepath.Join(repoDir, \".beads\")); err != nil {\n        return fmt.Errorf(\"run 'bd init --prefix <prefix>' or 'bd bootstrap' first\")\n    }\n    // config.yaml check: correct key is issue-prefix (hyphen)\n    if data, err := os.ReadFile(filepath.Join(repoDir, \"config.yaml\")); err == nil {\n        if bytes.Contains(data, []byte(\"issue_prefix:\")) {\n            return fmt.Errorf(\"config.yaml uses 'issue_prefix:'; rename to 'issue-prefix:'\")\n        }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"prefix, err := storage.ReadConfigPrefix(ctx, tx)\nif errors.Is(err, storage.ErrNotInitialized) {\n    // initialize then retry\n    if e := runBdInit(repoDir, defaultPrefix); e != nil { return e }\n    prefix, err = storage.ReadConfigPrefix(ctx, tx)\n}","preventionTips":["Run 'bd init --prefix <prefix>' after creating a repo; 'bd bootstrap' after cloning a remote.","In config.yaml always use the hyphenated key issue-prefix, never issue_prefix.","Add an init check to setup scripts/CI before any bd write command.","Verify initialization with a config read (SELECT value FROM config WHERE `key`='issue_prefix')."],"tags":["configuration","initialization","not-initialized","go"],"backgroundTag":"missing-issue-prefix-config","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}