{"record":{"id":"5879f0de7b1eb15a","repo":"benbjohnson/litestream","slug":"cannot-specify-both-meta-path-and-meta-dir","errorCode":null,"errorMessage":"cannot specify both 'meta-path' and 'meta-dir'","messagePattern":"cannot specify both 'meta-path' and 'meta-dir'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/litestream/main.go","lineNumber":824,"sourceCode":"\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdb.Replica = r\n\n\treturn db, nil\n}\n\n// NewDBsFromDirectoryConfig scans a directory and creates DB instances for all SQLite databases found.\nfunc NewDBsFromDirectoryConfig(dbc *DBConfig) ([]*litestream.DB, error) {\n\tif dbc.Dir == \"\" {\n\t\treturn nil, fmt.Errorf(\"directory path is required for directory replication\")\n\t}\n\n\tif dbc.Pattern == \"\" {\n\t\treturn nil, fmt.Errorf(\"pattern is required for directory replication\")\n\t}\n\tif dbc.MetaPath != nil && dbc.MetaDir != nil {\n\t\treturn nil, fmt.Errorf(\"cannot specify both 'meta-path' and 'meta-dir'\")\n\t}\n\n\tdirPath, err := expand(dbc.Dir)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Find all SQLite databases in the directory\n\tdbPaths, err := FindSQLiteDatabases(dirPath, dbc.Pattern, dbc.Recursive)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to scan directory %s: %w\", dirPath, err)\n\t}\n\n\tif len(dbPaths) == 0 && !dbc.Watch {\n\t\treturn nil, fmt.Errorf(\"no SQLite databases found in directory %s with pattern %s\", dirPath, dbc.Pattern)\n\t}\n\n\t// Create DB instances for each found database","sourceCodeStart":806,"sourceCodeEnd":842,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/cmd/litestream/main.go#L806-L842","documentation":"Directory replication lets you place per-database metadata either under a meta directory derived from each DB's relative path ('meta-dir') or via an explicitly derived meta path ('meta-path'). Specifying both is ambiguous, so NewDBsFromDirectoryConfig rejects the config upfront to prevent silent state corruption.","triggerScenarios":"Calling NewDBsFromDirectoryConfig with a DBConfig where both MetaPath and MetaDir are non-nil (both 'meta-path:' and 'meta-dir:' set in the same db stanza).","commonSituations":"Merging two example configs together; copying a single-DB config (which uses meta-path) into a directory-replication stanza (which uses meta-dir); enabling directory replication on an existing single-DB entry without removing the old meta-path key.","solutions":["Remove 'meta-path' and keep only 'meta-dir' (preferred for directory replication, since it derives per-DB paths automatically).","Alternatively remove 'meta-dir' and keep 'meta-path' if you need a custom per-DB metadata layout.","For single-database replication (no 'dir'), use 'meta-path' only."],"exampleFix":"# before\ndbs:\n  - dir: /data\n    pattern: \"*.db\"\n    meta-path: /var/lib/litestream/meta\n    meta-dir: /var/lib/litestream/meta\n\n# after\ndbs:\n  - dir: /data\n    pattern: \"*.db\"\n    meta-dir: /var/lib/litestream/meta","handlingStrategy":"validation","validationCode":"if dbc.MetaPath != nil && dbc.MetaDir != nil {\n    return fmt.Errorf(\"set only one of meta-path / meta-dir\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Standardize on `meta-dir` for directory replication and `meta-path` for single-DB configs.","When converting a single-DB stanza to directory replication, strip meta-path first.","Search config templates for both keys before merging configs."],"tags":["config","litestream","directory-replication","validation"],"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-14T00:17:10.932Z"}