{"record":{"id":"35adff6358e1bbf7","repo":"benbjohnson/litestream","slug":"database-config-d-cannot-specify-both-meta-pat","errorCode":null,"errorMessage":"database config #%d: cannot specify both 'meta-path' and 'meta-dir'","messagePattern":"database config #(.+?): cannot specify both 'meta-path' and 'meta-dir'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/litestream/main.go","lineNumber":524,"sourceCode":"\t\t\tkey := filepath.Clean(db.Path)\n\t\t\tif first, ok := seenPaths[key]; ok {\n\t\t\t\treturn fmt.Errorf(\"database config #%d: duplicate path %q (already used by database config #%d); each database can be listed only once\", idx+1, db.Path, first)\n\t\t\t}\n\t\t\tseenPaths[key] = idx + 1\n\t\t}\n\n\t\t// When using dir, pattern must be specified\n\t\tif db.Dir != \"\" && db.Pattern == \"\" {\n\t\t\treturn fmt.Errorf(\"database config #%d: 'pattern' is required when using 'dir'\", idx+1)\n\t\t}\n\t\tif db.Watch && db.Dir == \"\" {\n\t\t\treturn fmt.Errorf(\"database config #%d: 'watch' can only be enabled with a directory\", idx+1)\n\t\t}\n\t\tif db.MetaDir != nil && db.Dir == \"\" {\n\t\t\treturn fmt.Errorf(\"database config #%d: 'meta-dir' can only be used with a directory\", idx+1)\n\t\t}\n\t\tif db.MetaPath != nil && db.MetaDir != nil {\n\t\t\treturn fmt.Errorf(\"database config #%d: cannot specify both 'meta-path' and 'meta-dir'\", idx+1)\n\t\t}\n\n\t\t// Use path or dir for identifying the config in error messages\n\t\tdbIdentifier := db.Path\n\t\tif dbIdentifier == \"\" {\n\t\t\tdbIdentifier = db.Dir\n\t\t}\n\n\t\tif db.Snapshot.Interval != nil && *db.Snapshot.Interval <= 0 {\n\t\t\treturn &ConfigValidationError{\n\t\t\t\tErr:   ErrInvalidSnapshotInterval,\n\t\t\t\tField: fmt.Sprintf(\"dbs[%s].snapshot.interval\", dbIdentifier),\n\t\t\t\tValue: *db.Snapshot.Interval,\n\t\t\t}\n\t\t}\n\t\tif db.Snapshot.Retention != nil && *db.Snapshot.Retention <= 0 {\n\t\t\treturn &ConfigValidationError{\n\t\t\t\tErr:   ErrInvalidSnapshotRetention,","sourceCodeStart":506,"sourceCodeEnd":542,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/cmd/litestream/main.go#L506-L542","documentation":"Validate() rejects a database config entry specifying both 'meta-path' and 'meta-dir'. These are mutually exclusive ways to locate metadata: meta-path for a single database file, meta-dir for directory replication. Only one may be set.","triggerScenarios":"A databases[] entry in the config contains both `meta-path:` and `meta-dir:` keys; Validate runs during ParseConfig and fails with this message including the 1-based database index.","commonSituations":"User merges a single-DB config snippet (meta-path) with a directory snippet (meta-dir) into one entry; leftover key from a config refactor.","solutions":["Keep only meta-path if the entry targets a single database via `path:`.","Keep only meta-dir if the entry targets a directory via `dir:`.","Delete both to use default metadata locations."],"exampleFix":"# before\ndatabases:\n  - dir: /var/db\n    pattern: \"*.db\"\n    meta-path: /tmp/meta\n    meta-dir: /var/lib/meta\n# after\ndatabases:\n  - dir: /var/db\n    pattern: \"*.db\"\n    meta-dir: /var/lib/meta","handlingStrategy":"validation","validationCode":"if db.MetaPath != nil && db.MetaDir != nil {\n    return fmt.Errorf(\"db #%d: set only one of meta-path/meta-dir\", i+1)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never copy meta keys across dir/path entry types","Run a config linter that flags mutually exclusive keys","Keep one canonical config template per entry type"],"tags":["config","validation","litestream"],"backgroundTag":"mutually-exclusive-options","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"}