{"record":{"id":"183bd6b95e997a7a","repo":"gastownhall/beads","slug":"v","errorCode":null,"errorMessage":"%v","messagePattern":"%v","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/init.go","lineNumber":795,"sourceCode":"\t\t\t\t\t// the request and reuse a different database. --database is\n\t\t\t\t\t// the authoritative selector, so it is checked even when\n\t\t\t\t\t// --prefix is also set.\n\t\t\t\t\texisting := existingWorkspaceDBName()\n\t\t\t\t\tif cmd.Flags().Changed(\"database\") {\n\t\t\t\t\t\tif initIfMissingDatabaseMismatch(existing, database) {\n\t\t\t\t\t\t\treturn fmt.Errorf(\"workspace already initialized as database %q, but --database %q was requested.\\nRemove --database (or pass a matching value) to reuse the existing workspace\", existing, database)\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if cmd.Flags().Changed(\"prefix\") {\n\t\t\t\t\t\tif initIfMissingPrefixMismatch(existing, prefix) {\n\t\t\t\t\t\t\treturn fmt.Errorf(\"workspace already initialized as database %q, but --prefix %q was requested.\\nRemove --prefix (or pass a matching value) to reuse the existing workspace\", existing, prefix)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif !quiet {\n\t\t\t\t\t\tfmt.Fprintln(os.Stderr, \"Skipping init: workspace already initialized.\")\n\t\t\t\t\t}\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t\treturn fmt.Errorf(\"%v\", err)\n\t\t\t}\n\t\t}\n\n\t\t// Check BEADS_DB environment variable if --db flag not set\n\t\t// (PersistentPreRun doesn't run for init command)\n\t\tif dbPath == \"\" {\n\t\t\tif envDB := os.Getenv(\"BEADS_DB\"); envDB != \"\" {\n\t\t\t\tdbPath = envDB\n\t\t\t}\n\t\t}\n\n\t\t// Determine prefix with precedence: flag > config > auto-detect from git > auto-detect from directory name\n\t\tif prefix == \"\" {\n\t\t\t// Try to get from config file\n\t\t\tprefix = config.GetString(\"issue-prefix\")\n\t\t}\n\n\t\t// auto-detect prefix from directory name","sourceCodeStart":777,"sourceCodeEnd":813,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/init.go#L777-L813","documentation":"Generic wrapper: during bd init, an underlying workspace-check/initialization error (from checking whether the workspace already exists) is returned verbatim (%v) with no additional context. The real cause is whatever the inner existing-workspace probe returned — e.g. corrupted .beads config or an unreadable state.","triggerScenarios":"`bd init` in a directory where the existing-workspace detection call returns an error other than 'already initialized' (e.g. malformed .beads/config.yaml, permission problem reading workspace state).","commonSituations":"Partially deleted .beads directories; config files corrupted by merge conflicts; read-only mounts.","solutions":["Inspect .beads/config.yaml for corruption and fix or remove it","Re-run with verbose/debug output to surface the underlying error","If unrecoverable, back up and remove .beads, then run bd init again"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"bd doctor || echo \"resolve workspace issues before re-init\"","typeGuard":null,"tryCatchPattern":"if err := bdInit(); err != nil { return fmt.Errorf(\"bd init failed: %w — check .beads/config.yaml integrity\", err) }","preventionTips":["Keep .beads config files out of merge conflicts (commit a resolved version)","Run bd doctor before re-initializing suspect workspaces","Back up .beads before any cleanup operation"],"tags":["cli","init","wrapper"],"backgroundTag":"workspace-state-unreadable","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}