{"record":{"id":"f756d53eeef7df78","repo":"benbjohnson/litestream","slug":"no-snapshots-available","errorCode":null,"errorMessage":"no snapshots available","messagePattern":"no snapshots available","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"litestream.go","lineNumber":33,"sourceCode":"\t_ \"modernc.org/sqlite\"\n)\n\n// Naming constants.\nconst (\n\tMetaDirSuffix = \"-litestream\"\n)\n\n// SQLite checkpoint modes.\nconst (\n\tCheckpointModePassive  = \"PASSIVE\"\n\tCheckpointModeFull     = \"FULL\"\n\tCheckpointModeRestart  = \"RESTART\"\n\tCheckpointModeTruncate = \"TRUNCATE\"\n)\n\n// Litestream errors.\nvar (\n\tErrNoSnapshots      = errors.New(\"no snapshots available\")\n\tErrChecksumMismatch = errors.New(\"invalid replica, checksum mismatch\")\n\tErrLTXCorrupted     = errors.New(\"ltx file corrupted\")\n\tErrLTXMissing       = errors.New(\"ltx file missing\")\n\tErrDiskFull         = errors.New(\"disk full\")\n)\n\n// LTXError provides detailed context for LTX file errors with recovery hints.\ntype LTXError struct {\n\tOp      string // Operation that failed (e.g., \"open\", \"read\", \"validate\")\n\tPath    string // File path\n\tLevel   int    // LTX level (0 = L0, etc.)\n\tMinTXID uint64 // Minimum transaction ID\n\tMaxTXID uint64 // Maximum transaction ID\n\tErr     error  // Underlying error\n\tHint    string // Recovery hint for users\n}\n\nfunc (e *LTXError) Error() string {","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/litestream.go#L15-L51","documentation":"ErrNoSnapshots is returned when a restore finds no snapshot (LTX level-0) files on the replica to restore from. It is treated as a soft condition by db.go and the library examples: a fresh empty database will be created instead of failing.","triggerScenarios":"Replica.Restore/db.Replica.Restore on a replica whose storage has never completed a snapshot, after retention deleted all snapshots, or pointing restore at the wrong bucket/path/replica URL.","commonSituations":"Restoring a brand-new database before the first sync produced a snapshot; misconfigured S3 bucket or prefix; retention/lifecycle rules purged objects; using `litestream ltx` cleanup then immediately restoring.","solutions":["Verify the replica URL/bucket/prefix points at the storage that actually contains backups","Run `litestream ltx -level 0` against the replica to inspect available snapshots","Trigger a fresh sync/snapshot first, then restore","If an empty database is acceptable, handle errors.Is(err, ErrNoSnapshots) and proceed with a new DB"],"exampleFix":"// before\nif err := replica.Restore(ctx, opt); err != nil { return err }\n// after\nif err := replica.Restore(ctx, opt); err != nil {\n    if errors.Is(err, litestream.ErrNoSnapshots) {\n        log.Println(\"no backup found, creating fresh database\")\n        return nil\n    }\n    return err\n}","handlingStrategy":"fallback","validationCode":"// verify snapshots exist before restoring:\n// litestream ltx -level 0 -replica <url>\n// or in code, list replica contents and require >= 1 level-0 LTX file","typeGuard":null,"tryCatchPattern":"if err := replica.Restore(ctx, opt); err != nil {\n    if errors.Is(err, litestream.ErrNoSnapshots) || errors.Is(err, litestream.ErrTxNotAvailable) {\n        log.Println(\"no backup found, creating new database\")\n        return nil\n    }\n    return err\n}","preventionTips":["Confirm the first snapshot completed before relying on restores","Check retention settings so lifecycle rules never delete all level-0 files","Double-check bucket/prefix/replica URL when restores come up empty"],"tags":["restore","snapshot","replica","storage"],"backgroundTag":"empty-result-set","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"}