{"record":{"id":"dd13f4055e2b377f","repo":"benbjohnson/litestream","slug":"database-not-found-s","errorCode":null,"errorMessage":"database not found: %s","messagePattern":"database not found: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"store.go","lineNumber":384,"sourceCode":"\t}\n\n\ts.dbs = slices.Delete(s.dbs, idx, idx+1)\n\ts.mu.Unlock()\n\n\tif err := db.Close(ctx); err != nil {\n\t\treturn fmt.Errorf(\"close db: %w\", err)\n\t}\n\n\treturn nil\n}\n\n// EnableDB starts replication for a registered database.\n// The context is checked for cancellation before opening.\n// Note: db.Open() itself does not support cancellation.\nfunc (s *Store) EnableDB(ctx context.Context, path string) error {\n\tdb := s.FindDB(path)\n\tif db == nil {\n\t\treturn fmt.Errorf(\"database not found: %s\", path)\n\t}\n\n\tif db.IsOpen() {\n\t\treturn fmt.Errorf(\"database already enabled: %s\", path)\n\t}\n\n\t// Check for cancellation before starting open\n\tif err := ctx.Err(); err != nil {\n\t\treturn fmt.Errorf(\"enable database: %w\", err)\n\t}\n\n\tif err := db.Open(); err != nil {\n\t\treturn fmt.Errorf(\"open database: %w\", err)\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":366,"sourceCodeEnd":402,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/store.go#L366-L402","documentation":"EnableDB looks up a registered database by path before starting replication; if no DB with that exact path is registered in the Store, it returns this error. It is a lookup failure, not a filesystem check — the DB must have been registered (via config load or RegisterDB) first.","triggerScenarios":"Store.EnableDB(ctx, path) (via IPC handleStart) with a path that is not registered: typo in path, relative vs absolute path mismatch, or DB never registered / already unregistered.","commonSituations":"Sending a 'start' IPC command with a path that differs from the configured path (symlinks, relative paths, trailing slash); calling EnableDB before config registration completes; DB was removed by a concurrent unregister.","solutions":["Call Store.FindDB(path) first and confirm it is non-nil with the exact path","Use the absolute, cleaned path exactly as it appears in the litestream config (filepath.Abs + filepath.Clean)","List registered DBs (e.g. via IPC) and match the path string before enabling","Register the database first if it is genuinely missing from the store"],"exampleFix":"// before\nerr := store.EnableDB(ctx, \"data/app.db\") // relative path not registered\n// after\nabs, _ := filepath.Abs(\"data/app.db\")\nif store.FindDB(abs) == nil {\n    return fmt.Errorf(\"db not registered: %s\", abs)\n}\nerr := store.EnableDB(ctx, abs)","handlingStrategy":"validation","validationCode":"abs, err := filepath.Abs(path)\nif err != nil { return err }\nif store.FindDB(abs) == nil {\n    return fmt.Errorf(\"db not registered: %s\", abs)\n}","typeGuard":null,"tryCatchPattern":"if err := store.EnableDB(ctx, abs); err != nil {\n    if strings.Contains(err.Error(), \"database not found\") {\n        // list registered DBs and surface correct path\n    }\n    return err\n}","preventionTips":["Normalize paths with filepath.Abs + filepath.Clean before any store call","Use the same path string everywhere: config, registration, IPC","Resolve symlinks with filepath.EvalSymlinks if paths may be aliased"],"tags":["database","not-found","path"],"backgroundTag":"resource-not-found","analyzedSha":"4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3","analyzedAt":"2026-09-06T18:29:25.564Z","contentChangedAt":"2026-09-06T18:29:25.564Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}