fix: Add 'file:' prefix to SQLite URIs in doctor.go (#261)

Without the 'file:' URI scheme prefix, SQLite treats query parameters
like '?mode=ro' as part of the filename instead of connection options.
This caused:
- Creation of bogus files named 'beads.db?mode=ro'
- Failure to read database version from metadata table
- bd doctor incorrectly reporting 'version pre-0.17.5 (very old)'

Fixed two sql.Open() calls in doctor.go:
- Line 317 (checkIssueIDs function)
- Line 403 (getDatabaseVersionFromPath function)

Now uses 'file:'+dbPath+'?mode=ro' pattern consistent with migrate.go.

Fixes #260

Amp-Thread-ID: https://ampcode.com/threads/T-ac9832d6-15e4-4e25-8027-5e8b640b190b

Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
Matteo Landi
2025-11-08 20:36:42 +01:00
committed by GitHub
parent 4bca2067ff
commit 53c9e9bf89

View File

@@ -314,7 +314,7 @@ func checkIDFormat(path string) doctorCheck {
}
// Open database
db, err := sql.Open("sqlite3", dbPath+"?mode=ro")
db, err := sql.Open("sqlite3", "file:"+dbPath+"?mode=ro")
if err != nil {
return doctorCheck{
Name: "Issue IDs",
@@ -400,7 +400,7 @@ func checkCLIVersion() doctorCheck {
}
func getDatabaseVersionFromPath(dbPath string) string {
db, err := sql.Open("sqlite3", dbPath+"?mode=ro")
db, err := sql.Open("sqlite3", "file:"+dbPath+"?mode=ro")
if err != nil {
return "unknown"
}