{"record":{"id":"dbdd0e483bcce45c","repo":"benbjohnson/litestream","slug":"cannot-calc-restore-plan-w","errorCode":null,"errorMessage":"cannot calc restore plan: %w","messagePattern":"cannot calc restore plan: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"replica.go","lineNumber":688,"sourceCode":"\t}\n\n\t// Compare v0.3.x and LTX formats to find the best backup (unless TXID is specified).\n\t// Skip V3 format when follow mode is enabled (V3 doesn't support incremental following).\n\tif opt.TXID == 0 && !opt.Follow {\n\t\tif client, ok := r.Client.(ReplicaClientV3); ok {\n\t\t\tuseV3, err := r.shouldUseV3Restore(ctx, client, opt.Timestamp)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif useV3 {\n\t\t\t\treturn r.RestoreV3(ctx, opt)\n\t\t\t}\n\t\t}\n\t}\n\n\tinfos, err := CalcRestorePlan(ctx, r.Client, opt.TXID, opt.Timestamp, r.Logger())\n\tif err != nil {\n\t\treturn fmt.Errorf(\"cannot calc restore plan: %w\", err)\n\t}\n\n\tr.Logger().Debug(\"restore plan\", \"n\", len(infos), \"txid\", infos[len(infos)-1].MaxTXID, \"timestamp\", infos[len(infos)-1].CreatedAt)\n\n\trdrs := make([]io.Reader, 0, len(infos))\n\tdefer func() {\n\t\tfor _, rd := range rdrs {\n\t\t\tif closer, ok := rd.(io.Closer); ok {\n\t\t\t\t_ = closer.Close()\n\t\t\t}\n\t\t}\n\t}()\n\n\tfor _, info := range infos {\n\t\t// Validate file size - must be at least header size to be readable\n\t\tif info.Size < ltx.HeaderSize {\n\t\t\treturn fmt.Errorf(\"invalid ltx file: level=%d min=%s max=%s has size %d bytes (minimum %d)\",\n\t\t\t\tinfo.Level, info.MinTXID, info.MaxTXID, info.Size, ltx.HeaderSize)","sourceCodeStart":670,"sourceCodeEnd":706,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/replica.go#L670-L706","documentation":"CalcRestorePlan failed while determining the sequence of snapshot+incremental LTX files needed to reach the requested TXID/timestamp. Causes: replica listing errors, no snapshot available at all, or a gap in TXID history around the requested point.","triggerScenarios":"Thrown at replica.go:688 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify backups exist for the requested point in time (litestream ltx)","Check replica connectivity and credentials","Pick an earlier timestamp whose history is still retained"],"exampleFix":null,"handlingStrategy":"retry","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"}