{"record":{"id":"4d2cc28dfc744293","repo":"benbjohnson/litestream","slug":"oss-list-objects-page-w","errorCode":null,"errorMessage":"oss: list objects page: %w","messagePattern":"oss: list objects page: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"oss/replica_client.go","lineNumber":354,"sourceCode":"func (c *ReplicaClient) DeleteAll(ctx context.Context) error {\n\tif err := c.Init(ctx); err != nil {\n\t\treturn err\n\t}\n\n\tvar objects []oss.DeleteObject\n\n\t// Create paginator for listing objects\n\tprefix := c.Path + \"/\"\n\tpaginator := c.client.NewListObjectsV2Paginator(&oss.ListObjectsV2Request{\n\t\tBucket: oss.Ptr(c.Bucket),\n\t\tPrefix: oss.Ptr(prefix),\n\t})\n\n\t// Iterate through all pages\n\tfor paginator.HasNext() {\n\t\tpage, err := paginator.NextPage(ctx)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"oss: list objects page: %w\", err)\n\t\t}\n\n\t\t// Collect object identifiers\n\t\tfor _, obj := range page.Contents {\n\t\t\tif obj.Key != nil {\n\t\t\t\tobjects = append(objects, oss.DeleteObject{Key: obj.Key})\n\t\t\t}\n\t\t}\n\t}\n\n\t// Delete all collected objects in batches\n\tfor len(objects) > 0 {\n\t\tn := min(len(objects), MaxKeys)\n\t\tbatch := objects[:n]\n\n\t\trequest := &oss.DeleteMultipleObjectsRequest{\n\t\t\tBucket:  oss.Ptr(c.Bucket),\n\t\t\tObjects: batch,","sourceCodeStart":336,"sourceCodeEnd":372,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/oss/replica_client.go#L336-L372","documentation":"DeleteAll pages through ListObjectsV2 to enumerate all objects under the replica path before deleting them. A paginator.NextPage failure is wrapped as 'list objects page'. This precedes any deletion and usually indicates connectivity, auth, or bucket-state problems.","triggerScenarios":"DeleteAll (e.g. dropping a replica or 'litestream reset' cleanup) iterating listing pages when the token-based pagination breaks due to network error, AccessDenied on oss:ListObjects, or a removed bucket.","commonSituations":"RAM policy missing oss:ListObjects; bucket deleted externally mid-operation; long-running pagination across an unstable VPN/corporate network.","solutions":["Grant oss:ListObjects (List) permission to the RAM role.","Verify the bucket exists and endpoint/region are correct.","Retry; pagination is resumable via continuation tokens and transient failures are safe to reattempt.","Check network path stability if the failure occurs on later pages of a large object set."],"exampleFix":"// before (RAM policy)\n{\"Effect\":\"Allow\",\"Action\":[\"oss:PutObject\",\"oss:GetObject\",\"oss:DeleteObjects\"],\"Resource\":\"acs:oss:*:*:my-bucket/*\"}\n// after\n{\"Effect\":\"Allow\",\"Action\":[\"oss:PutObject\",\"oss:GetObject\",\"oss:ListObjects\",\"oss:DeleteObjects\"],\"Resource\":\"acs:oss:*:*:my-bucket/*\"}","handlingStrategy":"retry","validationCode":"if _, err := client.ListLTXFiles(ctx); err != nil { /* list permission broken; fix before running DeleteAll */ }","typeGuard":null,"tryCatchPattern":"err := client.DeleteAll(ctx)\nif err != nil {\n    if isTransient(err) { time.Sleep(backoff); return client.DeleteAll(ctx) }\n    return fmt.Errorf(\"delete all: %w\", err)\n}","preventionTips":["Grant oss:ListObjects in addition to read/write permissions.","Run DeleteAll over a reliable network; large buckets paginate many times.","Confirm the bucket exists before destructive operations."],"tags":["oss","list","pagination","storage"],"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-14T05:17:10.506Z"}