{"record":{"id":"26f02a2554e9d62a","repo":"benbjohnson/litestream","slug":"no-replica-configured-for-database-s","errorCode":null,"errorMessage":"no replica configured for database: %s","messagePattern":"no replica configured for database: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/litestream/replicate.go","lineNumber":492,"sourceCode":"\tdbPath, err := expand(dbConfig.Path)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Skip if database already exists\n\tif _, err := os.Stat(dbPath); !os.IsNotExist(err) {\n\t\tslog.Info(\"database exists, skipping restore\", \"path\", dbPath)\n\t\treturn nil\n\t}\n\n\t// Get replica config (handles both Replica and Replicas fields)\n\tvar rc *ReplicaConfig\n\tif dbConfig.Replica != nil {\n\t\trc = dbConfig.Replica\n\t} else if len(dbConfig.Replicas) > 0 {\n\t\trc = dbConfig.Replicas[0]\n\t} else {\n\t\treturn fmt.Errorf(\"no replica configured for database: %s\", dbPath)\n\t}\n\n\t// Create replica from config (nil db since we're just restoring)\n\tr, err := NewReplicaFromConfig(rc, nil)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"cannot create replica for restore: %w\", err)\n\t}\n\n\t// Attempt restore\n\topt := litestream.NewRestoreOptions()\n\topt.OutputPath = dbPath\n\n\tslog.Info(\"attempting restore before replication\", \"path\", dbPath)\n\tif err := r.Restore(ctx, opt); errors.Is(err, litestream.ErrTxNotAvailable) {\n\t\t// No backup exists yet (first start) - this is OK\n\t\tslog.Info(\"no backup found, starting fresh\", \"path\", dbPath)\n\t\treturn nil\n\t} else if err != nil {","sourceCodeStart":474,"sourceCodeEnd":510,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/cmd/litestream/replicate.go#L474-L510","documentation":"restoreIfNeeded found a database path that does not exist on disk but the DB config has neither a Replica nor any Replicas entry to restore it from. Restore-before-replication cannot proceed without a replica definition.","triggerScenarios":"Thrown at cmd/litestream/replicate.go:492 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add a replica (or replicas) section to the database config","Or pre-create the database file if no restore is intended"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}