{"record":{"id":"3d1a7448533d5674","repo":"benbjohnson/litestream","slug":"cannot-create-database-from-config-w","errorCode":null,"errorMessage":"cannot create database from config: %w","messagePattern":"cannot create database from config: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/litestream/reset.go","lineNumber":79,"sourceCode":"\t\t\t\tdbConfig = dbc\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\t// If no config found, check if database file exists\n\tif _, err := os.Stat(dbPath); os.IsNotExist(err) {\n\t\treturn fmt.Errorf(\"database does not exist: %s\", dbPath)\n\t} else if err != nil {\n\t\treturn fmt.Errorf(\"cannot access database: %w\", err)\n\t}\n\n\t// Create DB instance\n\tvar db *litestream.DB\n\tif dbConfig != nil {\n\t\tdb, err = NewDBFromConfig(dbConfig)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"cannot create database from config: %w\", err)\n\t\t}\n\t} else {\n\t\tdb = litestream.NewDB(dbPath)\n\t}\n\n\t// Check if meta path exists\n\tmetaPath := db.MetaPath()\n\tif _, err := os.Stat(metaPath); os.IsNotExist(err) {\n\t\tfmt.Printf(\"No local state to reset for %s\\n\", dbPath)\n\t\tfmt.Printf(\"Meta directory does not exist: %s\\n\", metaPath)\n\t\treturn nil\n\t}\n\n\tif *dryRun {\n\t\tfiles, err := localLTXFiles(db.LTXDir())\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"dry run failed: %w\", err)\n\t\t}","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/cmd/litestream/reset.go#L61-L97","documentation":"This error wraps any failure that occurs while constructing a litestream.DB from a serialized database config (TOML/JSON config snippet) during `litestream reset`. NewDBFromConfig parses the config and initializes the DB object; if the config is malformed, references a missing/invalid replica section, or fails internal validation, the underlying error is wrapped and returned. The reset command aborts before touching any local LTX state, so no data is deleted when this fires.","triggerScenarios":"Running `litestream reset -config litestream.yml` (or reset with a db path whose config stanza is resolved from the config file) where the db config block is invalid: unknown fields, bad DSN/path, invalid replica URLs, or a config that NewDBFromConfig cannot deserialize or validate.","commonSituations":"Typo'd or hand-edited config files; using a config generated for an older litestream version with renamed fields; pointing -config at a file with no matching db block; passing a replica URL where a db config was expected.","solutions":["Validate the config file with `litestream -config <file> ...` or by running another command (e.g. `litestream ltx`) that loads the same config, and fix the reported parse/validation error","Check the wrapped inner error (%w) in the message — it names the exact field or section that failed","Compare the db section against current litestream config docs for field renames after upgrading","If you only have a plain db path, omit -config/-db-config so reset falls back to litestream.NewDB(dbPath)"],"exampleFix":"// before (invalid config field)\ndbs:\n  - path: /var/lib/db/app.db\n    replicas:\n      - url: s3://BUCKET/prefix\n        sync-interval: sometimes\n// after\n dbs:\n  - path: /var/lib/db/app.db\n    replicas:\n      - url: s3://BUCKET/prefix\n        sync-interval: 1s","handlingStrategy":"validation","validationCode":"// Validate config before invoking reset\ncfg, err := os.ReadFile(configPath)\nif err != nil { return err }\nif !bytes.Contains(cfg, []byte(\"[[dbs]]\")) && !bytes.Contains(cfg, []byte(\"dbs:\")) {\n    return fmt.Errorf(\"config %s has no db sections\", configPath)\n}\n// smoke-test the same config through another command first:\n// litestream ltx -config <file> ...","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep db configs generated from one template/version; re-validate after upgrades","Run a non-destructive command with the same -config before running reset","Omit -config when you only have a plain db path"],"tags":["cli","config","reset"],"backgroundTag":"invalid-config-value","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"}