{"record":{"id":"5c8a9c8ae5b56b58","repo":"benbjohnson/litestream","slug":"invalid-ltx-file-level-d-min-s-max-s-has-size","errorCode":null,"errorMessage":"invalid ltx file: level=%d min=%s max=%s has size %d bytes (minimum %d)","messagePattern":"invalid ltx file: level=(.+?) min=(.+?) max=(.+?) has size (.+?) bytes \\(minimum (.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"replica.go","lineNumber":705,"sourceCode":"\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)\n\t\t}\n\n\t\tr.Logger().Debug(\"opening ltx file for restore\", \"level\", info.Level, \"min\", info.MinTXID, \"max\", info.MaxTXID)\n\n\t\trdrs = append(rdrs, internal.NewResumableReader(ctx, r.Client, info.Level, info.MinTXID, info.MaxTXID, info.Size, nil, r.Logger()))\n\t}\n\n\tif len(rdrs) == 0 {\n\t\treturn fmt.Errorf(\"no matching backup files available\")\n\t}\n\n\t// Create parent directory if it doesn't exist.\n\tvar dirInfo os.FileInfo\n\tif db := r.DB(); db != nil {\n\t\tdirInfo = db.dirInfo\n\t}\n\tif err := internal.MkdirAll(filepath.Dir(opt.OutputPath), dirInfo); err != nil {","sourceCodeStart":687,"sourceCodeEnd":723,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/replica.go#L687-L723","documentation":"Restore found an LTX file in the plan whose size is below ltx.HeaderSize, so its header cannot even be read. The remote file is truncated or corrupted (partial upload), making the restore chain unusable at that file.","triggerScenarios":"Thrown at replica.go:705 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Delete the truncated LTX object from the replica and force re-upload of that range","Run 'litestream ltx' to inspect replica file sizes and locate corruption"],"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-14T00:17:10.932Z"}