{"record":{"id":"b7a411358008e333","repo":"benbjohnson/litestream","slug":"list-snapshots-for-generation-s-w","errorCode":null,"errorMessage":"list snapshots for generation %s: %w","messagePattern":"list snapshots for generation (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"replica.go","lineNumber":1101,"sourceCode":"\t} else if !os.IsNotExist(err) {\n\t\treturn err\n\t}\n\n\t// Find all generations.\n\tgenerations, err := client.GenerationsV3(ctx)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"list generations: %w\", err)\n\t}\n\tif len(generations) == 0 {\n\t\treturn ErrNoSnapshots\n\t}\n\n\t// Collect all snapshots across all generations.\n\tvar allSnapshots []SnapshotInfoV3\n\tfor _, gen := range generations {\n\t\tsnapshots, err := client.SnapshotsV3(ctx, gen)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"list snapshots for generation %s: %w\", gen, err)\n\t\t}\n\t\tallSnapshots = append(allSnapshots, snapshots...)\n\t}\n\tif len(allSnapshots) == 0 {\n\t\treturn ErrNoSnapshots\n\t}\n\n\t// Sort all snapshots by CreatedAt for timestamp-based selection.\n\tsortSnapshotsV3ByCreatedAt(allSnapshots)\n\n\t// Find best snapshot across all generations (latest, or before timestamp if specified).\n\tsnapshot := findBestSnapshotV3(allSnapshots, opt.Timestamp)\n\tif snapshot == nil {\n\t\treturn ErrNoSnapshots\n\t}\n\n\tr.Logger().Debug(\"selected v0.3.x snapshot\",\n\t\t\"generation\", snapshot.Generation,","sourceCodeStart":1083,"sourceCodeEnd":1119,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/replica.go#L1083-L1119","documentation":"After listing generations, RestoreV3 iterates them and calls client.SnapshotsV3(ctx, gen) to collect snapshots per generation. A failure listing snapshots inside any single generation is wrapped as 'list snapshots for generation %s: %w' with the generation name included, pinpointing which generation's listing failed.","triggerScenarios":"Calling Replica.Restore when listing snapshot objects for one generation fails — typically a partial/corrupt generation directory in the storage backend, a storage API error (throttle, permission on a prefix), or a transient network failure mid-iteration over multiple generations.","commonSituations":"Backends with per-prefix permissions where one generation's prefix is inaccessible; S3 throttling while listing many generations; interrupted replication leaving a malformed generation that the backend cannot list; snapshot listing for a generation deleted between the GenerationsV3 and SnapshotsV3 calls.","solutions":["Read the wrapped cause and generation name to identify the failing generation and backend error","Check storage permissions on that generation's prefix and repair or remove the corrupt generation from the replica","Retry the restore; the failure may be transient throttling","If one generation is unrecoverable but others are healthy, this listing error still blocks restore — fix or delete the bad generation in storage"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// preflight: ensure every generation's snapshots are listable\nfor _, gen := range generations {\n    if _, err := client.SnapshotsV3(ctx, gen); err != nil {\n        return fmt.Errorf(\"generation %s not listable: %w\", gen, err)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := replica.Restore(ctx, opt); err != nil {\n    if strings.Contains(err.Error(), \"list snapshots for generation\") {\n        var genName string\n        fmt.Sscanf(err.Error(), \"list snapshots for generation %s\", &genName)\n        log.Printf(\"fix listing for generation %q, cause=%v\", genName, errors.Unwrap(err))\n        return err\n    }\n    return err\n}","preventionTips":["Keep storage permissions uniform across all generation prefixes","Audit and remove/repair generations with malformed or partial data","Watch for S3 throttling when many generations exist; consider compaction/cleanup","Monitor replication so interrupted generations are repaired promptly"],"tags":["go","restore","storage","s3","network"],"backgroundTag":"http-request-failed","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"}