{"record":{"id":"9da692cb045a26e6","repo":"benbjohnson/litestream","slug":"must-specify-replica-for-database","errorCode":null,"errorMessage":"must specify replica for database","messagePattern":"must specify replica for database","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/litestream/main.go","lineNumber":791,"sourceCode":"\tif dbc.BusyTimeout != nil {\n\t\tdb.BusyTimeout = *dbc.BusyTimeout\n\t}\n\tif dbc.MinCheckpointPageN != nil {\n\t\tdb.MinCheckpointPageN = *dbc.MinCheckpointPageN\n\t}\n\tif dbc.TruncatePageN != nil {\n\t\tdb.TruncatePageN = *dbc.TruncatePageN\n\t}\n\tif dbc.MaxSyncWALBytes != nil {\n\t\tdb.MaxSyncWALBytes = *dbc.MaxSyncWALBytes\n\t}\n\n\t// Instantiate and attach replica.\n\t// v0.3.x and before supported multiple replicas but that was dropped to\n\t// ensure there's a single remote data authority.\n\tswitch {\n\tcase dbc.Replica == nil && len(dbc.Replicas) == 0:\n\t\treturn nil, fmt.Errorf(\"must specify replica for database\")\n\tcase dbc.Replica != nil && len(dbc.Replicas) > 0:\n\t\treturn nil, fmt.Errorf(\"cannot specify 'replica' and 'replicas' on a database\")\n\tcase len(dbc.Replicas) > 1:\n\t\treturn nil, fmt.Errorf(\"multiple replicas on a single database are no longer supported\")\n\t}\n\n\tvar rc *ReplicaConfig\n\tif dbc.Replica != nil {\n\t\trc = dbc.Replica\n\t} else {\n\t\trc = dbc.Replicas[0]\n\t}\n\n\tr, err := NewReplicaFromConfig(rc, db)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdb.Replica = r","sourceCodeStart":773,"sourceCodeEnd":809,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/cmd/litestream/main.go#L773-L809","documentation":"NewDBFromConfig requires every database to have exactly one replication target. Since v0.3.x, multiple replicas were dropped to keep a single remote data authority; a DBConfig with Replica == nil and empty Replicas yields this error because there is nothing to replicate to.","triggerScenarios":"A databases[] entry defines a path (or dir) but no `replica:` section and no (deprecated) `replicas:` list; NewDBFromConfig is called from Run, newDBFromDirectoryEntry, or loadFromConfig.","commonSituations":"New config written with only the database path, forgetting the replica block; comment/template stripped the replica section; migration from an older config omitted replicas.","solutions":["Add a `replica:` section with a storage backend (e.g. `url: s3://bucket/db`) to the database entry.","If using directory replication, set the replica URL at the directory-config level as documented.","Verify the YAML indentation so the replica key is nested under the correct databases entry."],"exampleFix":"# before\ndatabases:\n  - path: /var/db/app.db\n# after\ndatabases:\n  - path: /var/db/app.db\n    replica:\n      url: s3://mybucket/litestream/app","handlingStrategy":"validation","validationCode":"if dbc.Replica == nil && len(dbc.Replicas) == 0 {\n    return fmt.Errorf(\"db #%d needs a replica\", i+1)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always include a replica block per database entry","Start from the official config template","Validate the full config before deploying"],"tags":["config","replica","litestream"],"backgroundTag":"missing-required-config-field","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"}