{"record":{"id":"baea6208247c3187","repo":"gastownhall/beads","slug":"recovery-w","errorCode":null,"errorMessage":"recovery: %w","messagePattern":"recovery: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/doltserver/doltserver.go","lineNumber":1987,"sourceCode":"\t\treturn false, nil // No .dolt/ directory — nothing to recover\n\t}\n\n\tmarkerPath := filepath.Join(doltDir, bdDoltMarker)\n\tif _, err := os.Stat(markerPath); err == nil {\n\t\treturn false, nil // Marker exists — database is from 0.56+\n\t}\n\n\tfmt.Fprintf(os.Stderr, \"Detected dolt database from an older bd version (pre-0.56).\\n\")\n\tfmt.Fprintf(os.Stderr, \"Rebuilding dolt database at %s ...\\n\", doltDir)\n\n\tif err := os.RemoveAll(dotDolt); err != nil {\n\t\treturn false, fmt.Errorf(\"cannot remove old dolt database at %s: %w\\n\\n\"+\n\t\t\t\"Manually delete %s and retry\", dotDolt, err, dotDolt)\n\t}\n\n\t// Reinitialize\n\tif err := ensureDoltInit(doltDir); err != nil {\n\t\treturn true, fmt.Errorf(\"recovery: %w\", err)\n\t}\n\n\treturn true, nil\n}\n\n// IsPreV56DoltDir returns true if doltDir contains a .dolt/ directory that\n// was NOT created by bd 0.56+ (missing .bd-dolt-ok marker). These databases\n// were created by the old embedded Dolt mode and may be incompatible.\n// Used by doctor checks to detect potentially problematic dolt databases.\nfunc IsPreV56DoltDir(doltDir string) bool {\n\tdotDolt := filepath.Join(doltDir, \".dolt\")\n\tif _, err := os.Stat(dotDolt); os.IsNotExist(err) {\n\t\treturn false // No .dolt/ at all\n\t}\n\tmarkerPath := filepath.Join(doltDir, bdDoltMarker)\n\t_, err := os.Stat(markerPath)\n\treturn os.IsNotExist(err)\n}","sourceCodeStart":1969,"sourceCodeEnd":2005,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/doltserver/doltserver.go#L1969-L2005","documentation":"Returned by RecoverPreV56DoltDir when the removal of the legacy pre-0.56 .dolt/ directory succeeded but the subsequent reinitialization via ensureDoltInit failed. This means the old database was deleted (data was unrecoverable anyway per GH#2137) but no fresh database was created — bd is left without an initialized dolt directory. The wrapped error is the underlying ensureDoltInit failure (directory creation or dolt init).","triggerScenarios":"RecoverPreV56DoltDir removes an old .dolt/ directory during a pre-0.56 upgrade, then ensureDoltInit fails — e.g. MkdirAll fails on a read-only/full filesystem, or 'dolt init' exits non-zero because the dolt binary is missing, too old, or rejects the directory.","commonSituations":"Upgrading bd to 0.56+ on a machine without the dolt CLI installed (the old embedded mode did not need it); half-completed recovery after fixing a partial removal permission issue; container image lacking the dolt binary.","solutions":["Read the wrapped cause: if it is the 'dolt init' error, install/repair the dolt binary and verify with `dolt version`","If the wrapped cause is a filesystem error, fix writability/space on doltDir, then re-run bd to retry recovery","If recovery left a broken partial state, delete .beads/.dolt and any partial files, then re-run bd to reinitialize from scratch","Once dolt works, confirm the .bd-dolt-ok marker exists in doltDir so future runs skip recovery"],"exampleFix":"// before (recovery deleted .dolt but 'dolt' binary missing)\n# error: recovery: dolt init: exec: \"dolt\": executable file not found in $PATH\n// after\n$ curl -L https://github.com/dolthub/dolt/releases/latest/download/dolt-linux-amd64.tar.gz | tar -xz\n$ mv dolt-linux-amd64/dolt /usr/local/bin/\n$ bd ready   # ensureDoltInit runs 'dolt init' successfully","handlingStrategy":"retry","validationCode":"if IsPreV56DoltDir(doltDir) {\n    if _, err := exec.LookPath(\"dolt\"); err != nil {\n        return fmt.Errorf(\"pre-0.56 database detected but dolt CLI missing; install dolt BEFORE triggering recovery\")\n    }\n    if err := os.MkdirAll(doltDir, 0o755); err != nil {\n        return fmt.Errorf(\"dolt dir not writable; recovery will fail after deleting .dolt: %w\", err)\n    }\n}","typeGuard":null,"tryCatchPattern":"performed, err := RecoverPreV56DoltDir(doltDir)\nif err != nil && strings.HasPrefix(err.Error(), \"recovery:\") {\n    // .dolt was already deleted; fix the cause (install dolt / fix perms) and retry safely\n    if rerr := ensureDoltInit(doltDir); rerr == nil {\n        return nil // recovered on retry\n    }\n    return err\n}","preventionTips":["Install/verify the dolt CLI (`dolt version`) before upgrading bd past 0.56","Ensure the filesystem is writable and has space before running version upgrades","After any failed recovery, re-run bd once the cause is fixed — retry is safe since old data is unrecoverable","Confirm .bd-dolt-ok appears after recovery to avoid re-entering the recovery path"],"tags":["dolt","recovery","upgrade","external-command"],"backgroundTag":"dolt-recovery-reinit-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}