{"record":{"id":"d3d6be08d0cccd9b","repo":"benbjohnson/litestream","slug":"db-path-required","errorCode":null,"errorMessage":"db path required","messagePattern":"db path required","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"store.go","lineNumber":348,"sourceCode":"\t\t\t\tdb.Logger.Error(\"close duplicate db\", \"path\", db.Path(), \"error\", err)\n\t\t\t}\n\t\t\treturn nil\n\t\t}\n\t}\n\n\ts.dbs = append(s.dbs, db)\n\ts.mu.Unlock()\n\n\t// Start heartbeat monitor if heartbeat is configured and monitor isn't running.\n\ts.startHeartbeatMonitorIfNeeded()\n\n\treturn nil\n}\n\n// UnregisterDB stops monitoring the database at the provided path and closes it.\nfunc (s *Store) UnregisterDB(ctx context.Context, path string) error {\n\tif path == \"\" {\n\t\treturn fmt.Errorf(\"db path required\")\n\t}\n\n\ts.mu.Lock()\n\n\tidx := -1\n\tvar db *DB\n\tfor i, existing := range s.dbs {\n\t\tif existing.Path() == path {\n\t\t\tidx = i\n\t\t\tdb = existing\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif db == nil {\n\t\ts.mu.Unlock()\n\t\treturn nil\n\t}","sourceCodeStart":330,"sourceCodeEnd":366,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/store.go#L330-L366","documentation":"Store.UnregisterDB requires a non-empty database path and returns this error for the empty string. Without a path there is nothing to look up in the store's registry. It is a caller misuse guard, raised before any locking or lookup occurs.","triggerScenarios":"Calling UnregisterDB(ctx, \"\") — commonly from a handler (handleUnregister) or path-removal helpers (removeDatabase, removeDatabasesUnder) that received an empty path from config parsing or an unset variable.","commonSituations":"Config file with an empty db path entry; a variable holding the db path never populated; CLI/API callers passing an empty string after trimming an invalid input.","solutions":["Pass the actual absolute path of the registered database to UnregisterDB","Validate/trim the path at config load and reject empty values early","If the path is unknown, list registered DBs (s.DBs()) to find the correct path"],"exampleFix":"// before\npath := cfg.DBPath // \"\"\nstore.UnregisterDB(ctx, path)\n\n// after\nif cfg.DBPath == \"\" {\n    return fmt.Errorf(\"config: db path must not be empty\")\n}\nreturn store.UnregisterDB(ctx, cfg.DBPath)","handlingStrategy":"validation","validationCode":"if path == \"\" {\n    return fmt.Errorf(\"db path must be a non-empty absolute path\")\n}","typeGuard":null,"tryCatchPattern":"if err := store.UnregisterDB(ctx, path); err != nil && err.Error() == \"db path required\" {\n    // caller passed empty path; fix input source, no retry\n}","preventionTips":["Validate db paths at config-load time and reject empty values","Use absolute, resolved paths when calling store APIs","Trim and check inputs from CLI flags or HTTP handlers before use"],"tags":["api","path","validation","store"],"backgroundTag":"missing-required-argument","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"}